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 |
|
ucal
Yak Posting Veteran
72 Posts |
Posted - 2008-10-15 : 19:38:30
|
| I have a table T1 with the following data structureID Flag Seq-- -- --1 a x 1 a y2 a t3 b t3 b u4 a m5 c u5 c kI want to create a table with distinct values ID and Flag.Any assistance will be welcomedExpected ResultsID Flag Seq-- -- --1 a Multiple2 a t3 b Multiple4 a m5 c Multiple |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-10-15 : 20:52:49
|
| select ID,Flag,case when count(seq)=2 then 'Multiple' else max(Seq) End as Seqfrom tablegroup by ID,Flag |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-10-15 : 21:12:46
|
| Or depending on data.select ID,Flag,case when count(seq)>=2 then 'Multiple' else max(Seq) End as Seqfrom tablegroup by ID,Flag |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-16 : 02:35:53
|
| or justselect ID,Flag,case when min(seq)<>max(seq) then 'Multiple' else max(Seq) End as Seqfrom tablegroup by ID,Flag |
 |
|
|
|
|
|