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.
| Author |
Topic |
|
ramana_cr
Starting Member
14 Posts |
Posted - 2002-01-09 : 15:46:16
|
| table1col1,col2, col3..,col4A1, A2, A3.., 1A1, A2, A4.., 1 A1, A3, A4.., 2.. ... .... .....for this record I want to get the 'current order'I can do it like thisSelect col1, max(col4) col4into temp_table from table1 group by col1Select a.* from table1 a , temp_table t1 where a.col1 = t1.col1AND a.col4 = t1.col4Can I do this in a single select statement.. if so howThanks |
|
|
ToddV
Posting Yak Master
218 Posts |
|
|
bm1000
Starting Member
37 Posts |
Posted - 2002-01-09 : 16:05:50
|
| /* use a correlated query. note the alias (a) */select * from table1 awhere col4 = (select max(col4) from table 1 where col1 = a.col1) |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-10 : 00:27:13
|
| How about this one.Select distinct top 1 * from table1 order by col4 descor Select distinct * from table1 where col4= (select max(col4) from table1)HTH----------------------------Anything that Doesn't Kills you Makes you Stronger |
 |
|
|
ramana_cr
Starting Member
14 Posts |
Posted - 2002-01-10 : 07:30:26
|
| Thank You very much guys... |
 |
|
|
|
|
|
|
|