i have a problems in joins. if i run two queries separately it runs fine but if run using joins its creating problem
and second query is
and if i join this query like this
its taking more than an hour to execute and
i was also getting error in conversion failed when converting the varchar value to data type int
bcoz cpt column is varchar but when i run separately no error occurs
please help me out
thanks in advance
Code:
SELECT Div, Bill, count(CPT)) as [Count(Paid Claims)],sum(ChgAmt)as [Charges Paid($)],sum(PayAmt)as [Payments($)], SUM(PayAmt) / SUM(ChgAmt) as [PMT/CHG(%)] ,sum(PayAmt)/ convert(int,count(CPT)) as [AVG PMT ($)] FROM dbo.PaymentFile group by Bill, Div order by Div asc, Bill asc
Code:
SELECT Div, Bill,count(CPT) as [Count(Claims)],sum(ChgAmt)as [Charges($)] FROM dbo.TransactionFile group by Bill, Div order by Div asc, Bill asc
Code:
SELECT t.Div, t.Bill, (t.CPT)) as [Count(Claims)], sum(t.ChgAmt)as [Charges($)], p.Div, p.Bill, (p.CPT))as [Count(Paid Claims)],sum(p.ChgAmt)as [Charges Paid($)], sum(p.PayAmt)as [Payments($)],(p.CPT))/(t.CPT)) as [Claims(Paid %)], sum(p.PayAmt)/sum(p.ChgAmt)as [PMT/CHG(%)], sum(p.PayAmt)/count(p.CPT) as [AVG PMT ($)] FROM dbo.TransactionFileas t,dbo.PaymentFile as p group by t.Bill, t.Div, p.Bill, p.Div order by t.Div asc, t.Bill asc
its taking more than an hour to execute and
i was also getting error in conversion failed when converting the varchar value to data type int
bcoz cpt column is varchar but when i run separately no error occurs
please help me out
thanks in advance
Comment