14,739,199 members
1.00/5 (1 vote)
See more:
Hi all!
I have a database with this table:
http://prntscr.com/8h43p4[^]

How to query output data the following results:
http://prntscr.com/8h44r5[^]

Thanks every one!
Posted
RedDk 16-Sep-15 17:18pm

Not going to follow those links. For help, post code and error messages that occur at runtime.
deepankarbhatnagar 17-Sep-15 3:10am

## Solution 2

Try this

```DECLARE @TBL TABLE
(
ID INT IDENTITY,
REPORTDATE DATETIME,
GAMENAME VARCHAR(50),
TOTAL  INT
)

INSERT INTO @TBL (REPORTDATE, GAMENAME, TOTAL)
SELECT '2015-09-05', 'Ninja Runner', 2000 UNION ALL
SELECT '2015-09-05', 'ZigZag', 1500 UNION ALL
SELECT '2015-09-05', 'Sky Force', 8000 UNION ALL
SELECT '2015-09-06', 'ZigZag', 300 UNION ALL
SELECT '2015-09-06', 'Sky Force', 2500 UNION ALL
SELECT '2015-09-07', 'Ninja Runner', 700 UNION ALL
SELECT '2015-09-07', 'Sky Force', 1000 UNION ALL
SELECT '2015-09-08', 'ZigZag', 10000

SELECT TMP.REPORTDATE, TMP.GAMENAME, ISNULL(T.TOTAL, 0)
FROM
(
SELECT distinct GAMENAME, A.REPORTDATE
FROM	@TBL
CROSS JOIN
(
SELECT '2015-09-03' as 'REPORTDATE' UNION ALL
SELECT '2015-09-04' UNION ALL
SELECT '2015-09-05' UNION ALL
SELECT '2015-09-06' UNION ALL
SELECT '2015-09-07' UNION ALL
SELECT '2015-09-08'
) A
) TMP LEFT OUTER JOIN @TBL T ON TMP.GAMENAME = T.GAMENAME AND TMP.REPORTDATE = T.REPORTDATE
order by 1, 2```
7045Jeegnesh 24-Sep-15 8:57am

really? Hardy...Did u Understand Question? and O @Mr.thang Explain that U need All Date Between Min To Max Date
_Asif_ 24-Sep-15 10:43am

Did you understand the answer? you probably need to look at the images again and try execute the script that i have provided :)
Mr.thang 31-Mar-16 0:40am

Thanks @_Asif_ !

## Solution 1

Select column_name, column_name, column_name from #report