Subject | Re: SQL Question |
---|---|
Author | Michael Vilhelmsen |
Post date | 2008-04-28T07:10:46Z |
--- In firebird-support@yahoogroups.com, Philippe Makowski
<makowski@...> wrote:
I cannot for sure know how many values there is in either X-Akse og
Y_Akse.
At least 1 in both.
<makowski@...> wrote:
>No - And I think this is the problem.
> Michael Vilhelmsen [08-04-25 14.49] :
> > I would like to fetch all rows as shown above.
> > Only I dont know the exact amount of ros or columns.
> > At least 1 of each ....
> >
> If you know one of them you can write something like that :
> (I suppose you know the different distinct values for X_AKSE)
I cannot for sure know how many values there is in either X-Akse og
Y_Akse.
At least 1 in both.
>
> 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
>