Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Grab Maximum Order Amount

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2011-02-01 : 11:53:39
I have the following:

SELECT dbo.AllOEOrders.*
FROM dbo.AllOEOrders
WHERE (CONVERT(varchar(8), entered_dt) = DATEADD([day], DATEDIFF([day], 0, GETDATE()), 0)) AND (ord_type <> 'Q') AND (status <> 'C')


I want to grab the record with the maximum tot_sls_amt

How can I add that to the code above?

SQL 2000

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-01 : 11:56:18
quote:
Originally posted by Vack

I have the following:

SELECT top 1 dbo.AllOEOrders.*
FROM dbo.AllOEOrders
WHERE (CONVERT(varchar(8), entered_dt) = DATEADD([day], DATEDIFF([day], 0, GETDATE()), 0)) AND (ord_type <> 'Q') AND (status <> 'C')
order by tot_sls_amt DESC


I want to grab the record with the maximum tot_sls_amt

How can I add that to the code above?

SQL 2000




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-02-02 : 00:35:54
if you are finding maximum order for an item then just group by the item.
Go to Top of Page
   

- Advertisement -