Hallo zusammen,
ich habe folgende SQL-Abfrage:
Die Abfrage klappt soweit auch. Schlussendlich möchte ich von jeder abgefragten Kalenderwoche eine Anzahl wissen. Falls jedoch in einer Woche kein Eintrag in der Tabelle ist, dann liefert mir MySQL auch nichts. Stattdessen möchte ich jedoch gerne 0 haben. Wie kann ich das umsetzen?
Die Ausgabe bisher sieht so aus:
Die fehlenden Wochen sollen aber mit 0 gespeichert werden.
ich habe folgende SQL-Abfrage:
SQL:
SELECT SUM(count_condition_id) AS sum_cci, Year, KW, condition_id
FROM alarmrankings
WHERE dienst = 'foobar'
AND (
condition_id = 'c706bac2-14ee-71d8-07ec-0a0104150000'
OR condition_id = 'c7166044-14ee-71d8-07ec-0a0104150000' )
AND (
( KW = '39' AND Year = '2006' )
OR ( KW = '40' AND Year = '2006' )
OR ( KW = '41' AND Year = '2006' )
OR ( KW = '42' AND Year = '2006' )
OR ( KW = '43' AND Year = '2006' )
OR ( KW = '44' AND Year = '2006' )
OR ( KW = '45' AND Year = '2006' )
OR ( KW = '46' AND Year = '2006' )
OR ( KW = '47' AND Year = '2006' )
)
GROUP BY condition_id, Year, KW
ORDER BY Year ASC, KW ASC, condition_id ASC
Die Ausgabe bisher sieht so aus:
Code:
Array
(
[c706bac2-14ee-71d8-07ec-0a0104150000] => Array
(
[39] => 1271
[40] => 1494
[41] => 1820
[42] => 1634
)
[c7166044-14ee-71d8-07ec-0a0104150000] => Array
(
[39] => 1271
[40] => 1494
[41] => 1818
[42] => 1641
)
)