Subject | Re: [firebird-support] Re: SQL Question |
---|---|
Author | Philippe Makowski |
Post date | 2008-04-25T20:21:15Z |
Michael Vilhelmsen [08-04-25 14.49] :
(I suppose you know the different distinct values for X_AKSE)
SELECT Y_AKSE,
SUM(CASE WHEN X_AKSE='BLACK' THEN FIELDVALUE ELSE NULL END) BLACK,
SUM(CASE WHEN X_AKSE='WHITE' THEN FIELDVALUE ELSE NULL END) WHITE,
SUM(CASE WHEN X_AKSE='GREY' THEN FIELDVALUE ELSE NULL END) GREY
FROM MYTABLE GROUP BY 1
> I would like to fetch all rows as shown above.If you know one of them you can write something like that :
> Only I dont know the exact amount of ros or columns.
> At least 1 of each ....
>
(I suppose you know the different distinct values for X_AKSE)
SELECT Y_AKSE,
SUM(CASE WHEN X_AKSE='BLACK' THEN FIELDVALUE ELSE NULL END) BLACK,
SUM(CASE WHEN X_AKSE='WHITE' THEN FIELDVALUE ELSE NULL END) WHITE,
SUM(CASE WHEN X_AKSE='GREY' THEN FIELDVALUE ELSE NULL END) GREY
FROM MYTABLE GROUP BY 1