i have a problems in joins. if i run two queries separately it runs fine but if run using joins its creating problem - 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
and second query is - 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
and if i join this query like this - 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
1 2203
Check your JOIN syntax....
Happy Coding!!!
~~ CK
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Xenophobe |
last post by:
I know this isn't a MySQL forum, but my question is related to a PHP
project.
I have two tables.
table1
table2
"table1" contains 2 columns, ID and FirstName:
|
by: Ira |
last post by:
I'm on a hosted Linux server and I have an Outer Join query that's returning
on one less row than I expect. There are two rows very similar and I
expect them both returned. There are similar...
|
by: Omavlana |
last post by:
Hi,
I need your help to resolve this problem. I have written a right outer
join query between 2 indipendent tables as follows.
select b.Account_desc, b.Account, a.CSPL_CSPL from...
|
by: Omavlana |
last post by:
Hi,
I need your help to resolve this problem. I have written a right outer
join query between 2 indipendent tables as follows.
select b.Account_desc, b.Account, a.CSPL_CSPL from...
|
by: Shahzad |
last post by:
dear respected gurus,
I would like to knew how to apply append,insert query for a self table
where no primary keys issues.
i do have problem say there are 5 rows of single record, this is data...
|
by: CSN |
last post by:
I have a pretty simple select query that joins a table
(p) with 125K rows with another table (pc) with almost
one million rows:
select p.*
from product_categories pc
inner join products p
on...
|
by: mcyi2mr3 |
last post by:
Hi
Help! Im stuck on a join query.
Im trying to get distinct (the same row returned only once) user_id and
forename from a tbl of users (they are always distinct) where user_id
in that tbl...
|
by: dikkuuhh |
last post by:
At the moment i have this query:
SELECT number, COUNT( * ) as count ' .
FROM visit ' .
RIGHT JOIN visitHit ON ( visitHit.visitId = visit.id ) AND ( type
= "link" )
WHERE ( brochureId = 57 )...
|
by: Luke |
last post by:
I have 3 tables (table1, table2, table3), all of them contain same
columns ( id, code, date1, date2, date3) and I need to get out by
'code' field all records that:
1. are in all 3 tables (this is...
|
by: bravo |
last post by:
hi
i need to optimize the join query, which joins three tables
say table1 ,table2 , table3 each having huge volume of records...
the query is as
select table1.id,table2.time,table3.Status
from...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |