|
My First table has My second table has but i failed to display like this count (resid) from first table, sum(val) from only sec table --> where cond is mid in (2,3) When i tried to join i am getting the sum of all the columns in first table
(comments are locked)
|
|
My answer is very similar to @Kev Riley's (so much so that I didn't post it once I saw his...), but with your latest requirement, here goes: The load statements are specific to SQL 2008 and later, but the select statement (which is the important part here) will work in previous editions.
(comments are locked)
|
|
If the second table already has the sum(val) aggregated by mId, then you need to join differently gives
Edit : OP has clarified the output requirements Try this hi .. but i need the output like this 5( 2 and 3 count) 30 ( 2 annd 3 val sum from first table) so the output should look like 5 30
Jun 06 '11 at 04:54 AM
Bhuvans
so the output should look like 5 30 1 row affected
Jun 06 '11 at 04:55 AM
Bhuvans
have updated my answer to give you your output - this doesn't use a join, but 2 sub selects - not sure how to 'join' these 2 datasets as they are simply 2 aggregates presented side-by-side
Jun 06 '11 at 05:00 AM
Kev Riley ♦♦
yeah ur right.. but ur first one helped me... thank you
Jun 06 '11 at 05:20 AM
Bhuvans
(comments are locked)
|


Hey guys.. do we have any solution for the above scenario
@Bhuvans : have patience, you asked the question 8 minutes before
@Bhuvans - adding 'please' somewhere would have helped too ...
hey guys.. pardon me