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
 SQL Server Development (2000)
 SQL question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-16 : 09:44:45
Ramana Reddy writes "Hi.. I have data in a table

table1
col1,col2, col3..,col4
A1, A2, A3.., 1
A1, A2, A4.., 1
A1, A3, A4.., 2
.. ... .... .....


for this record I want to get the 'current order'

I can do it like this

Select col1, max(col4)
into temp_table
from table1
group by col1.

Select a.* from table1 a , temp_table t1
where a.col1 = t1.col1
AND a.col4 = t1.col4..

Can I do this in a single select statement.. if so how

Thanks"

Nazim
A custom title

1408 Posts

Posted - 2002-01-16 : 09:52:19
Using Derive Query you can do it

Select a.* from table1 a , (
Select col1, max(col4) as col2
from table1
group by col1 ) b
where a.col1=b.col1 and a.col4=b.col4

Hope this does what you are looking for.

----------------------------------
"True love stories don't have endings."
Go to Top of Page
   

- Advertisement -