Timeline for How get the sum of two tables value using inner join
Current License: CC BY-SA 3.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 24, 2015 at 21:49 | comment | added | ypercubeᵀᴹ | Yeah, CROSS or OUTER APLY would work fine. | |
Jun 24, 2015 at 21:48 | comment | added | Kenneth Fisher | @ypercube That's what I thought. And it would need 4 inline subqueries. Although I suppose you could use CROSS APPLY. | |
Jun 24, 2015 at 21:47 | comment | added | ypercubeᵀᴹ |
@user1663855 check my answer in a similar problem here: Help with this query. Kenneth's answer is like my "option 3" (my favourite!) and inline subqueries is "option 1". Option 2 is unusable in your case because SUM() is different than COUNT() .
|
|
Jun 24, 2015 at 21:45 | comment | added | ypercubeᵀᴹ | I don't think so. With inline subqueries, yes. With window function, I can't think of a way that would use them and avoid the derived tables, like your query. | |
Jun 24, 2015 at 21:40 | comment | added | Kenneth Fisher | I am curious @ypercube is this possible to do with window functions? It didn't seem like an obvious way to do it for me. | |
S Jun 24, 2015 at 21:39 | history | suggested | M.I.M.F | CC BY-SA 3.0 |
i changed the GROUP BY clause at Return Cheque table...
|
Jun 24, 2015 at 21:16 | review | Suggested edits | |||
S Jun 24, 2015 at 21:39 | |||||
Jun 24, 2015 at 21:11 | comment | added | ypercubeᵀᴹ | Why do you need another way? This is perfectly good, if not the best. | |
Jun 24, 2015 at 21:10 | comment | added | M.I.M.F | Chris can you show me other way to solve this solution.. | |
Jun 24, 2015 at 21:08 | comment | added | Chris | @user1663855: There may be other ways to solve this query, but they aren't going to be "better" or much more compact than the answer Kenneth has given. | |
Jun 24, 2015 at 21:02 | comment | added | Kenneth Fisher | LEFT JOIN is absolutely correct. Sorry about that. I read JOIN in the question and was going to mention the LEFT JOIN in the text but got in a hurry and forgot. Thanks for the catch @Chris ! | |
S Jun 24, 2015 at 21:00 | history | suggested | Chris | CC BY-SA 3.0 |
I changed the JOINS to LEFT JOINS to avoid dropping client who had no return checks.
|
Jun 24, 2015 at 21:00 | vote | accept | M.I.M.F | ||
Jun 24, 2015 at 20:59 | comment | added | M.I.M.F | YES Kenneths Answer is correct instead of using JOIN for LEFT JOIN.. and thanks Chris.. Any good solutions instead of this answer... and please explain the answer how answer came. | |
Jun 24, 2015 at 20:43 | comment | added | Chris |
Kenneth has it basically right. To fix the missing clients use LEFT JOIN instead of JOIN to avoid removing clients for whom there are no returned checks.
|
|
Jun 24, 2015 at 20:41 | review | Suggested edits | |||
S Jun 24, 2015 at 21:00 | |||||
Jun 24, 2015 at 20:27 | comment | added | M.I.M.F | Thanks for the answer but answer is incorrect.. only display one person account value... i wanted to display the answer like the above 2nd image.. | |
Jun 24, 2015 at 20:17 | history | answered | Kenneth Fisher | CC BY-SA 3.0 |