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
 SQL Server Development (2000)
 Concatenate columns into rows

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-09 : 08:34:59
Catherine writes "The data I am working with is apartments and premiums (fireplace, garage, etc). The premium codes in my example are letters of the aphabet to simplify my example.

I am writing a report that needs to list each apartment number with the premium codes out beside it. For example:

Unit  Code
111 ABCD
112 CD
113 FVEE


I am using Crystal Reports Version 8.1.1, MS SQL Server Version 7 (No service pack), and Win NT Server 4.0 (service pack 6). I already called Crystal support and they said there is no way to do what I want within the report designer.

Below is the SQL code I have so far. My problem is that it does not loop to include more than one premium code.

create table #test(
PropertyNumber char(10) null,
Unit varchar(10) null,
Value int null,
Code varchar(30) null);
insert into #test
select PropertyNumber,
UnitApartmentNumber,
sum(PremiumValue),
null
from UnitPremiumView
where PropertyNumber = '1'
group by PropertyNumber, UnitApartmentNumber;
update #test
set Code = Code+PremiumCode
from UnitPremiumView
where PremiumValue&Value > 0;


ANY SUGGESTIONS? I did not see anything this complex on your site."

   

- Advertisement -