on 01-20-2010 7:14 PM
{'2009_'.Order Date}<>maximum{'2009_'.Order Date}
I tried to use this formula to surpress details
It doesn't work
What am I doing wrong.
I only want to see the records with the most recent order date. I don't want to use grouping
The option I could think of is TOP N(Bottom N where N=1) using Group sort expert.
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can't use a summary function formula in record selection, so you have to push it out to a custom SQL command:
Select top 1 <row data>
from TABLE
where <conditions>
SORT BY dateobject DESC
This sorts your data at the database in order of most to least recent, then returns only the top or most recent row.
Fuskie
Who hopes this helps...
Thanks again for your help.
I tried the following:
SELECT top 1 `'2009_'`.`Order Date`
FROM `'2009$'` `'2009_'`
where `'2009_'`.`Order Date` is not null
SORT BY `'2009_'`.`Order Date` desc
I am getting an error message:
Database Connection Error 'DAO Error Code OxcO3
Source DAO.Database
Description : Syntax error (missing operator) in query expression
'`'2009_'.Order Date is not null
SORT BY `'2009_'.`Order Date ` desc'.'
Can you help?
Thanks
OK, then use the custom SQL command to just replace the order table in the report. Assuming your ORDER table has a FIRM_ID, ORDER_ID and a ORDER_DATE, try this:
SELECT FIRM_ID, ORDER_ID, ORDER_DATE, <any other order information you need from the table>
FROM ORDER
WHERE ORDER_DATE = (select order_date from order_sub where (FIRM_ID = order_sub.firm_id) and (ORDER_DATE = maximum(order_sub.order_date))
If I did this right, your SQL command runs a sub-query that determines the most recent order date for the specified firm, then limits the main query to rows for the firm with that order date. Now you will still get multiple rows if the firm has more than one order on its most recent order date. You can get around this by dealing with the Order # instead of date, since the Order ID should be unique.
SELECT FIRM_ID, ORDER_ID, ORDER_DATE, <any other order information you need from the table>
FROM ORDER
WHERE ORDER_DATE = (select order_date from order_sub where (FIRM_ID = order_sub.firm_id) and (ORDER_ID = maximum(order_sub.order_id))
This should return the most recent order for a firm, period.
Fuskie
Who finds himself writing much more custom SQL these days than he did a dozen years ago when he was first starting with Crystal Reports...
Thanks once again for yor gracious assistance.
I Tried the following:
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` ,
`'2009_'`.`Appraiser `,
`'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
WHERE `'2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from order_sub where (`'2009_'`.`Firm ID`=order_sub `'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`))
It returns the following error:
Description Missing ),} or item in query expression
'2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from order_sub where (`'2009_'`.`Firm ID`=order_sub `'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`))'.'
what am I doing wrong?
>
> what am I doing wrong?
You listened to me. Looks like I left off a close parenthesis from my example:
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` ,
`'2009_'`.`Appraiser `,
`'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
WHERE `'2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from order_sub where (`'2009_'`.`Firm ID`=order_sub `'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`)))
Fuskie
Who notes the third close parenthesis to complete the select sub-query...
I think you are missing a period after order_sub."2009_".'Firm ID':
'2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from order_sub where (`'2009_'`.`Firm ID`=order_sub.`'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`)))
Fuskie
Who notes proof reading queries is a good exercise to become more familiar with query development...
Thanks,
I may be getting closer
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` ,
`'2009_'`.`Appraiser `,
`'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
where
'2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from order_sub where (`'2009_'`.`Firm ID`=order_sub.`'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`)))
Syntax error (missing operator) in query expression ''2009_'`.`'.'
I tried adding a ` before the '2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from order_sub where (`'2009_'`.`Firm ID`=order_sub.`'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`)))
Now I get this error
The Microsoft Jet database engine could not find the object 'order_sub'. Make sure the object exists and that spell its name and path correctly.'
I want to award you 1000 points for your effort.
I am still getting an error:
This what I used
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` ,
`'2009_'`.`Appraiser `,
`'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
where
`'2009_'`.`Order Date`=(select `'2009_'`.`Order Date` from `'2009$'` `'2009_'` as order_sub where (`'2009_'`.`Firm ID`=order_sub.`'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`)))
Syntax error in query expression
'2009_'`.`Order Date` from `'2009$'` `'2009_'` as order_sub where (`'2009_'`.`Firm ID`=order_sub.`'2009_'`.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`'2009_'`.`Order Date`)))','
Try this.
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` , `'2009_'`.`Appraiser `, `'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
WHERE `'2009_'`.`Order Date`=(select `order_sub.`Order Date` from `'2009$'` order_sub where (`'2009_'`.`Firm ID`=order_sub.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`Order Date`)))
Fuskie
Who hopes this works...
I am still getting an error.
when I used
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` , `'2009_'`.`Appraiser `, `'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
WHERE `'2009_'`.`Order Date`=(select `order_sub.`Order Date` from `'2009$'` order_sub where (`'2009_'`.`Firm ID`=order_sub.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`Order Date`)))
Description Missing ),} or item in query expression `'2009_'`.`Order Date`=(select `order_sub.`Order Date` from `'2009$'` order_sub where (`'2009_'`.`Firm ID`=order_sub.`Firm ID`) and (`'2009_'`.`Order Date` = maximum(order_sub.`Order Date`)))
','
Try this.
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` , `'2009_'`.`Appraiser `, `'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
WHERE `'2009_'`.`Order Date`=(select "order_sub".`Order Date` from `'2009$'` "order_sub" where (`'2009_'`.`Firm ID`="order_sub".`Firm ID`) and (`'2009_'`.`Order Date` = maximum("order_sub".`Order Date`)))
Fuskie
Who really hates reading SQL queries with quotes enabled...
I can't thank you enough for your help.
I am still getting an error.
I used
SELECT `'2009_'`.`Firm ID`, `'2009_'`.`Order #`, `'2009_'`.`Order Date` , `'2009_'`.`Appraiser `, `'2009_'`.`City`, `'2009_'`.`Active`
FROM `'2009$'` `'2009_'`
WHERE `'2009_'`.`Order Date`=(select "order_sub".`Order Date` from `'2009$'` "order_sub" where (`'2009_'`.`Firm ID`="order_sub".`Firm ID`) and (`'2009_'`.`Order Date` = maximum("order_sub".`Order Date`)))
Returns the following error
Description : Invalid use of '.','!', or ()' in query expression 'order_sub". `Order Date`','
User | Count |
---|---|
74 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.