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 |
|
postmaster.chris
Starting Member
3 Posts |
Posted - 2006-05-11 : 12:13:52
|
| I have a table with these fields:Products_ID, ID_num, Description, Pricewith data like this:1, 112A, Item1, 3.332, 112A, Item2, 23.323, 382B, Item3, 392.35, 382A, Item4, 3.236, 382B, Item5, 2.38And I need the Query to produce these results:1, 112A, Item1, 3.333, 382B, Item3, 392.35, 382A, Item4, 3.23The Query should return only distinct ID_num's. It should get all the ID_num's in the table, but if there are duplicate ID_num's it should only return the 1st one found, along with the other table data for the row.I'm stumped!Any help appreciated! |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-05-11 : 12:16:01
|
| select *from tbl twhere t.Products_ID in (select min(Products_ID) from tbl group by ID_num)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
postmaster.chris
Starting Member
3 Posts |
Posted - 2006-05-11 : 12:31:19
|
I spent 4 hours on this problem. And you replied in 3 minutes!!! Thank you sooooo much! |
 |
|
|
|
|
|
|
|