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.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 SQL QUERY

Author  Topic 

antony_dba
Starting Member

26 Posts

Posted - 2010-11-29 : 02:36:09
TABLE1

Suggest the query for the result table...

a b c
- - -
1 3 23
1 4 32
2 5 32

i need the result table as

a b c
- - -
1 3 23
- 4 32
2 5 -


kris

kris

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2010-11-29 : 02:44:30
This looks more a reporting need and should be handles in the front end.
If you necessarily want to do this with an sql query, You should have an identity field there. Do you have one there ?
Go to Top of Page

antony_dba
Starting Member

26 Posts

Posted - 2010-11-29 : 02:47:59
how to specify the null values for duplication values in sql query


kris
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-29 : 07:36:44
This is something that should be done in the front end, in the reporting tool, not in the database.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-29 : 07:49:47
lol

select
a=case when aseq=1 then a else null end ,
b=case when bseq=1 then b else null end ,
c=case when cseq=1 then c else null end
from (
select a,b,c,
aseq = row_number() over (partition by a order by a,b,c),
bseq = row_number() over (partition by b order by a,b,c),
cseq = row_number() over (partition by c order by a,b,c)
from Table1
) a
order by a.a, a.b, a.c


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-29 : 08:46:07
This feature is known as Suppress if duplicated. If you want to show data in a front end application, do this there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -