On 5/29/2012 4:44 PM, Gert Van Assche wrote:
I have a strange table like this
rowid; Field1x; Field2y; FieldAx; FieldBy
1; A; a; 0; 1
2; B; b; 4; 2
and I would need this:
rowid; Field3; FieldC
1; A; 0
2; a; 1
3; b; 2
4; B; 4
Something like this perhaps:
select
(case when FieldAx < FieldBy then Field1x else Field2y end) as Field3,
(case when FieldAx < FieldBy then FieldAx else FieldBy end) as FieldC
from MyTable
union all
select
(case when FieldAx >= FieldBy then Field1x else Field2y end) as Field3,
(case when FieldAx >= FieldBy then FieldAx else FieldBy end) as FieldC
from MyTable;
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users