Subject | Re: [firebird-support] SQL Question |
---|---|
Author | Fidel Viegas |
Post date | 2008-04-25T10:16:58Z |
On Fri, Apr 25, 2008 at 10:35 AM, Michael Vilhelmsen
<Michael.Vilhelmsen@...> wrote:
You can try this:
select distinct t.y_akse, t1.fieldvalue, t2.fieldvalue
from tablename t
join tablename t1
on t.y_akse = t1.y_akse
join tablename t2
on t.y_akse = t2.y_akse
where t1.x_akse = 'BLACK' and t2.x_akse = 'WHITE';
tablename is the name of your table, since you have not provided one i
just called it tablename.
This returns your desired output, but maybe someone may come up with a
more efficient way of achieving this.
All the best,
Fidel.
<Michael.Vilhelmsen@...> wrote:
> HiHi Michael,
>
> I have a table.
> It contains data like:
>
> Y_AKSE X_AKSE FIELDVALUE
> -------------------------
> 46 BLACK 1
> 48 BLACK 2
> 50 BLACK 3
> 46 WHITE 4
> 48 WHITE 5
> 50 WHITE 6
>
> I would like to do a SELECT statement, that returns something like:
>
> 46 1 4
> 48 2 5
> 50 3 6
>
> Which is the numbers represented by BLACK and WHITE.
> Im not sure it can be done, but if it can it will help a lot.
>
> The problem is, that Y_AKSE can have a lot of distinct values as can
> X_AKSE.
> This example is just a short simple on.
You can try this:
select distinct t.y_akse, t1.fieldvalue, t2.fieldvalue
from tablename t
join tablename t1
on t.y_akse = t1.y_akse
join tablename t2
on t.y_akse = t2.y_akse
where t1.x_akse = 'BLACK' and t2.x_akse = 'WHITE';
tablename is the name of your table, since you have not provided one i
just called it tablename.
This returns your desired output, but maybe someone may come up with a
more efficient way of achieving this.
All the best,
Fidel.