All,
I have the following problem...
I am running the following query :
SELECT Items.Type, Hour([Time]) AS [Hour], Sum(Sales.Qty) AS Qty
FROM Sales INNER JOIN Items ON Sales.Item = Items.Item
GROUP BY Items.Type, Hour([Time]);
Result of this query is as follows :
Type1 Hour1 Qty
Type1 Hour2 Qty
Type2 Hour1 Qty
Type2 Hour2 Qty
Etc.
I use this to put the sales / hour / type in graphs.
Problem however is that i need to fix the x-axis of the graph in that way that i alwa's get the same format (e.g. all hours, even if not given a result in the query)
So, the query can come back with the following hours :
Type Hr Qty
Type1 00 10
Type1 01 15
Type1 02 8
Type1 08 30
Type1 14 50
But i need it to return
Type Hr Qty
Type1 00 10
Type1 01 15
Type1 02 8
Type1 03 0
Type1 04 0
Type1 05 0
Type1 06 0
Type1 07 0
Type1 08 30
...
Type1 23 0
Anybody any idea on how to do this
I worked it out using another table containing all possible hours and an inner join, that works fine. However, i can't have extra queries / tables in the database. This query needs to be directly in the graphs data source. "In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
I have the following problem...
I am running the following query :
SELECT Items.Type, Hour([Time]) AS [Hour], Sum(Sales.Qty) AS Qty
FROM Sales INNER JOIN Items ON Sales.Item = Items.Item
GROUP BY Items.Type, Hour([Time]);
Result of this query is as follows :
Type1 Hour1 Qty
Type1 Hour2 Qty
Type2 Hour1 Qty
Type2 Hour2 Qty
Etc.
I use this to put the sales / hour / type in graphs.
Problem however is that i need to fix the x-axis of the graph in that way that i alwa's get the same format (e.g. all hours, even if not given a result in the query)
So, the query can come back with the following hours :
Type Hr Qty
Type1 00 10
Type1 01 15
Type1 02 8
Type1 08 30
Type1 14 50
But i need it to return
Type Hr Qty
Type1 00 10
Type1 01 15
Type1 02 8
Type1 03 0
Type1 04 0
Type1 05 0
Type1 06 0
Type1 07 0
Type1 08 30
...
Type1 23 0
Anybody any idea on how to do this
I worked it out using another table containing all possible hours and an inner join, that works fine. However, i can't have extra queries / tables in the database. This query needs to be directly in the graphs data source. "In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963