May 26, 2008 at 7:15 pm
Is it possible to hide data showing when running queries ?
Like this
Customer Region Quarter (07) Sales$
123 ON 1 1000
123 ON 2 2000
123 ON 3 1500
123 ON 4 3000
222 BC 1 5000
instead I prefer to have like this
Customer Region Quarter (07) Sales$
123 ON 1 1000
2 2000
3 1500
4 3000
222 BC 1 5000
Thanks for any ideas and I know something could be done under
Reporting Services. (but I would know if any luck at query level)
May 26, 2008 at 8:02 pm
Can it be done? Yes.
Should it be done? No.
This is a presentation problem and it should be handled by the presentation layer, NOT the data manipulation layer.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
May 26, 2008 at 9:10 pm
... providing that there is a presentation layer... 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
May 26, 2008 at 10:15 pm
Francis... you already have the hardpart done... if the Quarter = 1 then show the column, otherwise show a blank. Simple case statement should do it.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 26, 2008 at 10:22 pm
Jeff Moden (5/26/2008)
... providing that there is a presentation layer... 😉
Heh. Well, unless they're displaying with SSMS, there's *something* doing the presentation, otherwise, why try to format it?
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
May 26, 2008 at 11:04 pm
No SSMS in 2k... no reporting service in 2k. Could be, it's a simple text report created by a scheduled job... makes a "great" presentation layer for those that don't actually have one.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 27, 2008 at 8:53 am
Thanks for all the suggestions and advices.
May 28, 2008 at 4:00 am
mmm... I do agree with Jeff and rbarryyoung , we can do it in presentation Layer.
But we can also do it in Data Layer. Here is the code,
----------------------------------------------------------------------
create table #test
(
Customer int,
Region char(2),
Quarter int,
Sales int
)
Insert into #test
select 123,'ON',1,1000
union all
select 123,'ON',2,2000
Union all
Select 123,'ON',3,1500
union all
select 123,'ON',4,3000
Union all
Select 222,'BC',1,5000
Select Customer, Region = case when Quarter = 1 then Region else Null End ,Quarter,Sales from #test
-------------------------------------------------------------------------------------------------
karthik
May 28, 2008 at 4:03 am
CustomerRegionQuarterSales
123ON11000
12322000
12331500
12343000
222BC15000
I got the above output.
Jeff and rbarryyoung , kindly add your comments, if my approach is wrong.
karthik
May 28, 2008 at 5:55 am
Heh... no, the approach is not wrong... it's exactly what I suggested earlier. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
May 28, 2008 at 6:45 am
ok.
karthik
June 9, 2008 at 8:52 am
declare @t table(Customer int, Region varchar(2), Quarter tinyint, Sales money)
declare @t2 table(Customer int, Region varchar(2), Quarter tinyint, Sales money)
insert @t
select 123 , 'ON' , 1 , 1000
union all select 123 , 'ON' , 2 , 2000
union all select 123 , 'ON' , 3 , 1500
union all select 222 , 'BC' , 1 , 5000
union all select 123 , 'ON' , 4 , 3000
insert @t2
select * from @t
order by Customer, Quarter
select nCustomer= case when b.customer is null then convert(varchar(50),a.customer) else '' end
, nRegion = case when b.region is null then convert(varchar(50),a.region) else '' end
, a.quarter, a.sales
from @t2 a
left join @t2 b on a.customer=b.customer and b.quarter=a.quarter-1
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply