Anybody that is way better than me please help.
For the life of me I can not get this to work.


select * from (

select * from table1 where Field2='Red' order by Field1 limit 1

union all

select * from table1 where Field2='White' and
Field1 < (select Field1 from table1 where Field2='Red' order by Field1
limit 1)
order by Field1 desc limit 4

union all

select * from table1 where Field2='Blue' and
Field1 < (select Field1 from table1 where Field2='Red' order by Field1
limit 1)
order by Field1 desc limit 1

union all

select * from table1 where Field2='White' and
Field1 > (select Field1 from table1 where Field2='Red' order by Field1
limit 1)
order by Field1 limit 4

union all

select * from table1 where Field2='Blue' and
Field1 > (select Field1 from table1 where Field2='Red' order by Field1
limit 1)
order by Field1 limit 1

)
order by Field1;
-- 
View this message in context: 
http://www.nabble.com/Union%2C-limit%2C-order-query-issues-tp20761996p20761996.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to