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 |
|
geoffsmiths
Starting Member
7 Posts |
Posted - 2010-05-26 : 10:16:03
|
| Hi there,I've got no more hair because of this single frustrating issue:I've got the following:ID | DATA_ID | URL | STORE_ID-----------------------------1 | 24 | bla | 102 | 11 | lol | 113 | 24 | Jak | 124 | 59 | iop | 5I want as result:ID | DATA_ID | URL | STORE_ID-----------------------------1 | 24 | bla | 103 | 24 | Jak | 12How do I manage this in an SQL query?Please help!!My regards,Geoff |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-05-26 : 10:34:24
|
select t1.ID, t1.DATA_ID, t1.URL, t1.STORE_IDfrom your_table t1join (select DATA_ID from your_table group by DATA_ID having count(*) > 1)dton dt.DATA_ID = t1.DATA_IDorder by t1.DATA_ID, t1.IDedit: order by was wrong No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-26 : 10:36:05
|
| select t1.* from table as t1 inner join(select data_id from table group by data_id having count(*)>1) as t2on t1.data_id=t2.data_idMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-26 : 10:37:01
|
MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-05-26 : 10:38:32
|
quote: Originally posted by madhivanan
MadhivananFailing to plan is Planning to fail
Haha. This time I was bit faster But maybe you can help on this topic with your dynamic pivot?I am too stupid for this:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=145174 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
geoffsmiths
Starting Member
7 Posts |
Posted - 2010-05-26 : 10:46:54
|
| Thanx, that worked! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-05-26 : 10:50:27
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|