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 |
|
Session101
Starting Member
15 Posts |
Posted - 2006-07-31 : 12:17:24
|
| I currently have a query that will display two entries if they have the same attributes (namely, quantity and price). Here is my current query:select id, quantity, pricefrom store tjoin store con t.quantity = c.quantityand t.price = c.priceMy problem is that I only want the query to display only 2 entries withthe same price and quantity. If a third entry apears with the same attributes, I do not want it to be displayed. I have been trying to use the function count, but I can't seem to get it to work. TIA. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-07-31 : 12:24:12
|
| select t.id, t.quantity, t.pricefrom store tjoin (select minid = min(id), maxid = max(id) from store group by quantity, price having count(*) > 1) t2on t.id = t2.minidor t.id = t2.maxid==========================================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. |
 |
|
|
|
|
|