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
 General SQL Server Forums
 New to SQL Server Programming
 rows into column structure help needed

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2014-05-19 : 22:23:49
Hi

can anyone help me to get the result set:

AwardNumber AwardDt AwardType_RSS AwardQty_RSS
A1 01/01/2004 RSS 100

QUERY:

create table structure(
AWARDNUMBER VARCHAR(10),
AWARDDT DATEtime,
AWARDTYPE CHAR(3),
QTYAWARDED DECIMAL(20,6)
)

insert into structure
select 'A1','1/1/2004',null,null
union all
select null,null,'RSS',100



current output:

AWARDNUMBER AWARDDT AWARDTYPE QTYAWARDED
NULL NULL RSS 100.000000
A1 2004-01-01 00:00:00.000 NULL NULL



TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2014-05-19 : 23:42:12
i think you'll need to provide more rows of sample data. Because all you need to do to get your result set is:
select max(awardNumber), max(awardDt), max(awardtype) as AwardTypeRSS, Max(awardQty) as awardQty_RSS from [structure]

For instance will other rows have different award types? How will you know which AwardNumber and AwardDt goes with which AwardType?

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -