I have this query which pulls the data correctly but I'd like the timestamp field (TIM) to be in another format than Day(TIM). But I get errors because the query is aggregating that way.
SELECT
DAY(TIM) As 'Day',
[G.TRU] = SUM(case when SEC = 'TRU' and TYP = 'GEO' then 1 else 0 end),
[G.LOA] = SUM(case when SEC = 'LOA' and TYP = 'GEO' then 1 else 0 end),
[G.SEA] = SUM(case when SEC = 'SEA' and TYP = 'GEO' then 1 else 0 end),
[R.SEA] = SUM(case when SEC = 'SEA' and TYP = 'RTE' then 1 else 0 end),
TOTAL = COUNT(TIM)
FROM AGEO
WHERE SRC = 'EW'
GROUP BY DAY(TIM)
Result:
Day G.TRU G.LOA G.SEA R.SEA TOTAL
-----------------------------------------------
25 2 4 14 1 21
26 3 0 2 9 14
-----------------------------------------------
I'd prefer the 25 and 26 to be in a YYYY-MM-DD format. Is there a way?