Note that there are some explanatory texts on larger screens.

plurals
  1. POJoining 3 SQL queries into one result set
    text
    copied!<p>here are the 3 queries the important thing is all three queries are based on date range and need to match up qry 1 assestnumber with snissued and snredeemed. thanks in advance</p> <pre><code>select assetnumber, sum(mocalc),sum(micalc), sum(cocalc),sum(cicalc) from drops where dropdate &gt; '09/01/2012' and dropdate &lt; dateadd(hour,-0,getdate()) group by assetnumber select snissued,sum(amount) from tickets where dateissued &gt; '09/01/2012' and dateissued &lt; dateadd(hour,-0,getdate()) group by snissued select snredeemed,sum(amount) from tickets where dateredeemed &gt; '09/01/2012' and dateredeemed &lt; dateadd(hour,-0,getdate()) group by snredeemed </code></pre> <p>in the first i am summing the 4 fileds i am using and grouping by the assetnumber for specified date range</p> <p>2nd i am pulling from another table sum of amounts for snissued for date range 3rd i am pulling from another table sum of amounts for snredeemed fore date range</p> <p>for the output i want the first table then 2 more colums snissued(sum amounts) and snredeemed (sum amounts)</p> <p>here is the current output</p> <pre><code>qry 1 0-2459-36182 843 869 14 40 0-2621-31924 64700 86900 3000 25200 0-2739-41401 5702 5738 204 236 </code></pre> <p>qry 2</p> <pre><code>0-2459-36182 162800 0-2621-31924 145000 0-2739-41401 298200 </code></pre> <p>qry 3</p> <pre><code>0-2459-36182 157200 0-2621-31924 157800 0-2739-41401 292800 </code></pre> <p>this is result i want</p> <pre><code>0-2459-36182 843 869 14 40 162800 157200 0-2621-31924 64700 86900 3000 25200 145000 157800 0-2739-41401 5702 5738 204 236 298200 292800 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload