PDA

View Full Version : SQL Issue



N_R_D
Aug 30th, 2006, 09:12 PM
I use sql analyzer from Microsoft....

here is what I need help with


Loan number....................Call type
123456................................120
123456................................118


I need a way to show this


Loan Number......Type1......Type2
1233456..............120..........118


How ?

oracleguy
Aug 30th, 2006, 09:52 PM
How about maybe showing us the query too?

N_R_D
Aug 30th, 2006, 10:03 PM
select a.CALACT, a.CALDAT, a.CALTIM, a.calopr, a.CALLOG, a.caltyp
into #POACallDocCodes
from Contact.dbo.phnlog as a
WHERE a.CALACT >0
AND a.CALDAT BETWEEN '6/1/2006' and '6/30/2006'
AND a.CALLOG IN ('C','T')
group by a.CALACT, a.CALDAT, a.CALTIM, a.calopr, a.CALLOG, a.caltyp

select a.CALACT, a.CALDAT, a.CALTIM, a.calopr, a.CALLOG, a.caltyp, b.doccode
into #docCodeDataHolderCodes
from #POACallDocCodes as a
left join CSRReporting.dbo.CSSDLOGF01 as b
on (a.CALACT=b.docacct#) and (a.CALDAT=b.docdate) and (a.calopr=b.docusrid)
where b.doccode IN ('116', '200', '208', '508', '130', '72', '564', '565')

select a.CALACT, a.CALDAT, a.CALTIM, a.CALLOG, a.CALTYP, a.doccode, b.txtdsc
from #docCodeDataHolderCodes as a
left join DEV.dbo.QC_CCS0100F03 as B
on (a.doccode=b.txtcode)
group by a.CALACT, a.CALDAT, a.CALTIM, a.caltyp, a.CALLOG, a.doccode, b.txtdsc

Roelf
Sep 1st, 2006, 07:08 AM
O dont know how to incorporate this into your query, but i have done this once by a join to the table itself:


SELECT T1.loannumber As [Loan number], T1.calltype As [Type 1], T2.calltype As [Type 2]
FROM tablename T1
INNER JOIN tablename T2
ON T2.loannumber = T1.loannumber