Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with the crosstab problem in sqlserver.

Status
Not open for further replies.

garry1

Programmer
Dec 6, 2002
49
0
0
US
Hi All,

When I run following query

SELECT distinct TOP 50 c.id,
a.UnitQty,
MIN(b.PeriodBeginDt),
MAX(b.PeriodEndDt),
b.SBAmt,
b.BdgAmt,
f.cttypecd
FROM tSBU a, tSB b, tCS c, tcbg e, tctr f
WHERE c.Id = b.Id
AND c.Id = e.Id
AND c.id = f.id
AND c.SeqNum = b.SeqNum
AND c.SeqNum = e.SeqNum
AND c.SeqNum = f.SeqNum
AND a.BillId = b.BillId
AND c.SSeqNum = b.SSeqNum
AND b.PeriodEndDt >= (Select min(PeriodEndDt) From tBS Where MonthDt = '01/01/2003' )
AND b.PeriodEndDt <= (Select max(PeriodEndDt) From tBS Where MonthDt = '05/01/2005' )
group by c.id, a.UnitQty,b.SBAmt, b.BdgAmt, f.cttypecd
order by c.custid, MIN(b.PeriodBeginDt),MAX(b.PeriodEndDt)

I am getting the result as

1 12.3 2003-05-06 2003-06-04 7.93 33.00 RE
1 12.3 2003-05-06 2003-06-04 12.86 23.00 RE

But I am looking for something like this

1 12.3 2003-05-06 2003-06-04 7.93 12.86 33.00 23.00 RE

Any help is very much appreciated.

Thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top