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 |
|
rahulsh
Starting Member
1 Post |
Posted - 2012-02-18 : 04:31:21
|
| Hi All,I have a table of three columns containing name,version and data.There can be multiple tuples of same name but with different version. From each group of same names, I want to delete those tuples for which the version is smallest.ExNAME VERSION DATAA 1 nethingA 2 nethingB 3 nethingB 3 nethingB 4 nethingafter operation, the tuples left in the table must be A 2 nethingB 4 nethingPlease help me out in this query. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-02-18 : 06:26:22
|
| SELECT NAME, MAX(VERSION) Ver, DATAINTO #aFROM myTableGROUP BY NAME, DATATRUNCATE TABLE myTableINSERT myTable(NAME, VERSION, DATA) SELECT NAME, Ver, DATA FROM #a |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-18 : 15:33:56
|
| will data be same value always?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|