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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Multiple SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-10-29 : 08:26:17
Prathap writes "Guys,

I am right now executing the following statement.

Select Max(Revenue),Customer from Table1
where DATE between '01-SEP-2004' and '30-SEP-2004'
and Primary_col_no = 'XXXXXXX'
Group by Y

The Result is
Max(Revenue) Customer

10000 Y1
20000 Y2
19000 Y3

Now my requirement is I should be able to select Max(Customer) as Y2 which corresponds to Max(revenue).

Kindly Advice.

Thx"

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-29 : 08:40:07
[code]
Select top 1 Max(Revenue), Customer from Table1
where DATE between '01-SEP-2004' and '30-SEP-2004'
and Primary_col_no = 'XXXXXXX'
Group by Y
Order By 1
[/code]

Corey
Go to Top of Page
   

- Advertisement -