Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use MAX on a field in record selection

Status
Not open for further replies.

nord

MIS
Aug 5, 2002
21
0
0
US
I'm trying to get the record that has the latest date. Right now I'm getting two records. How do I get the more current record only, based on the date field?
 
Thanks Naith,

My next hurdle is how to ge tthe SQL statement into the record selection. I tried this with the Select Expert, but I dont see a maximum in the drop down. DO I have to go into the Show SQL Query to modify it manually?
 
If you actually write out:

{Whatever} = Maximum({Whatever}), then that will be passed to the SQL. Even if it isn't, Crystal will sort it for you so that you only see the greatest value.

You don't write the SQL in the record selection. You write the clause, and Crystal generates the SQL at runtime.

Naith
 
I don't think that will work in the record selection criteria, Naith...

Try using a SQL Expression that returns the maximum date, as with SQL Server, but then you have GROUP BY concerns if there are other fields involved:

max(MyDate)

I'd use an SP or View.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top