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 2000 Forums
 Transact-SQL (2000)
 group report

Author  Topic 

tran008
Starting Member

38 Posts

Posted - 2004-08-17 : 11:40:52
Hi all,

How would I go around and generate the following report:

f1, f2, f3
1a, xx, xx
1a, x2, xx
2b, 2b, 2b
2b, 2x, 2b
2b, 3x, 3b

to something like this:
f1, f2, f3
1a, xx, xx
-- x2, xx
2b, 2b, 2b
-- 2x, 2b
-- 3x, 3b

thanks

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-17 : 12:00:49
Why wouldn't you do that in the presentation layer (ie. asp)??

Corey
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-17 : 12:06:30
Just because I show you, doesn't mean its the right thing to do. I still think presentation layer would be best.


Declare @table table (id int identity(1,1) not null, col1 varchar(100), col2 varchar(100))

Insert Into @table Values ('a4','b1')
Insert Into @table Values ('a2','b1')
Insert Into @table Values ('a1','b2')
Insert Into @table Values ('a3','b2')
Insert Into @table Values ('a3','b1')
Insert Into @table Values ('a3','b3')
Insert Into @table Values ('a1','b1')


Select
col1,
col1_n = case when exists(Select * From @table Where id < A.id and col1 = A.col1) then '--' else col1 end,
col2
From @table as A
Order By A.col1


Corey
Go to Top of Page

tran008
Starting Member

38 Posts

Posted - 2004-08-17 : 12:24:49
thanks
Go to Top of Page

tran008
Starting Member

38 Posts

Posted - 2004-08-17 : 12:25:03
thanks
Go to Top of Page
   

- Advertisement -