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 |
|
franman
Starting Member
3 Posts |
Posted - 2011-10-05 : 12:25:58
|
| Hi to everyone,Compliments for the website very useful and powerful I have a question, I hope someone can help me, I'll try to be as much clear as I can.I need to use clausole GROUP BY one thing that I know when I use it I have to select the same column.So is it possible to say ok for the aggregate rows I want select a custom value I mean a constant 'MORE'.I try to explain in another way to be much clearI have this tableA B C D_ _ _ ___1 2 3 ita 1 2 3 fra1 2 3 eng4 4 4 fraI want obtain this A B C D_ _ _ ___1 2 3 MORE 4 4 4 fraBut in the follow method doesn't work because all rows will have 'MORE'select A, B, C, 'MORE' as D from Tablewhere ...GROUP BY A, B, C, DPlease can you suggest me something I still looking for help, I tried to serch in your forum and on google as well but nothing.Thank you very much in advance.Francesco |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-05 : 12:29:38
|
| [code]select A, B, C,CASE WHEN COUNT(*) > 1 THEN 'MORE' ELSE MAX(D) END as D from Tablewhere ...GROUP BY A, B, C[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
franman
Starting Member
3 Posts |
Posted - 2011-10-05 : 12:35:22
|
Wow I never used something like that,Thank you very much I am going to try straight away! Francesco |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-05 : 12:42:00
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
franman
Starting Member
3 Posts |
Posted - 2011-10-06 : 06:34:00
|
| I want to say to everyone that it works perfectly!Thousands of Thanks :-)Francesco |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-06 : 08:41:59
|
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|