Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly your question, you want just one query with 3 results.</p> <p>You could use a <a href="http://msdn.microsoft.com/en-us/library/ms180026.aspx" rel="nofollow"><code>union all</code></a>.</p> <p>This will combine the 3 queries with the different date intervals. You will get back one resultset with 3 rows. </p> <p><strong>UPDATE</strong></p> <p>You could combine the queries like this (not tested, not at my pc)</p> <pre><code>SELECT TOP (100) PERCENT Sum(DBO.ORDERLINE.QTY) AS UnitsSold, { fn HOUR(dbo.[Order].PaymentDate) } AS MyHour FROM DBO.[ORDER] INNER JOIN DBO.ORDERLINE ON DBO.[ORDER].ORDERID = DBO.ORDERLINE.ORDERID WHERE ( DBO.[ORDER].WEBSITEID = 2 ) AND ( DBO.[ORDER].ORDERSTATUSID = 2 ) AND ( Day(DBO.[ORDER].PAYMENTDATE) = 01 ) AND ( Month(DBO.[ORDER].PAYMENTDATE) = 08 ) AND ( Year(DBO.[ORDER].PAYMENTDATE) = 2013 ) GROUP BY { fn HOUR(dbo.[Order].PaymentDate) } union all SELECT TOP (100) PERCENT Sum(DBO.ORDERLINE.QTY) AS UnitsSold, { fn HOUR(dbo.[Order].PaymentDate) } AS MyHour FROM DBO.[ORDER] INNER JOIN DBO.ORDERLINE ON DBO.[ORDER].ORDERID = DBO.ORDERLINE.ORDERID WHERE ( DBO.[ORDER].WEBSITEID = 2 ) AND ( DBO.[ORDER].ORDERSTATUSID = 2 ) AND ( Day(DBO.[ORDER].PAYMENTDATE) = 24 ) AND ( Month(DBO.[ORDER].PAYMENTDATE) = 07 ) AND ( Year(DBO.[ORDER].PAYMENTDATE) = 2013 ) GROUP BY { fn HOUR(dbo.[Order].PaymentDate) } union all SELECT TOP (100) PERCENT Sum(DBO.ORDERLINE.QTY) AS UnitsSold, { fn HOUR(dbo.[Order].PaymentDate) } AS MyHour FROM DBO.[ORDER] INNER JOIN DBO.ORDERLINE ON DBO.[ORDER].ORDERID = DBO.ORDERLINE.ORDERID WHERE ( DBO.[ORDER].WEBSITEID = 2 ) AND ( DBO.[ORDER].ORDERSTATUSID = 2 ) AND ( Day(DBO.[ORDER].PAYMENTDATE) = 01 ) AND ( Month(DBO.[ORDER].PAYMENTDATE) = 08 ) AND ( Year(DBO.[ORDER].PAYMENTDATE) = 2012 ) GROUP BY { fn HOUR(dbo.[Order].PaymentDate) } </code></pre> <p>You will get 3 rows with your data. If you want you can also add a fake columon saying wich is what (today, lastweek, last year) for the chart</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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