On 11/29/08, Webmaster <[EMAIL PROTECTED]> wrote:
> I have never posed in a group before forgive me if I am out of line with my
>  question.
>
>  I have a table called table1
>  With three fields: Field1, Field2, Field3
>
>  Here is my query but I get errors.
>  Any help work be great

Please provide more details... the table schema, number of rows in the
table, sample data, and most importantly, the actual errors you are
getting.

That said, the query below is, if you don't mind it, absolutely...
what description should I use... a rat's maze.

How about constructing views out of each component query, testing to
see each view works, then building up from that till you actually
encounter whatever errors you are getting?


>
>  select field1, field2 from
>  ( select * from ee_table1
>    where field2 = 'blue' limit 1
>    and field1 < (select min(field1) from (select  * from ee_table1
>                                        where field2 = 'white' limit 4
>                                        and field1 < (select field1 from
>  ee_table1 where field2 = 'red' limit 1 ) order by field1 desc) a )
>    order by field1 desc
>  ) previous_blue
>
>  union all
>
>  select field1,field2 from
>  ( select * from ee_table1
>    where field2 = 'white' limit 4
>       and field1 < (select field1 from ee_table1 where field2 = 'red' limit
>  1)
>    order by field1 desc
>  ) previous_5_white
>
>  union all
>
>  (select field1, field2 from ee_table1 where field2 = 'red' limit 1)
>
>  union all
>
>  select field1,field2 from
>  (  select * from ee_table1
>    where field2 = 'white' limit 4
>       and field1 > (select field1 from ee_table1 where field2 = 'red' limit
>  1)
>    order by field1 asc
>  ) next_5_white
>
>  union all
>
>  select field1,field2 from
>  (  select * from ee_table1
>    where field2 = 'blue' limit 1
>    and field1 > (select max(field1) from (select * from ee_table1
>                                        where field2 = 'white' limit 4
>                                        and field1 > (select field1 from
>  ee_table1 where field2 = 'red' limit 1) order by field1 asc) a )
>    order by field1 asc
>  ) previous_blue
>
>
>
>
>  Thanks in advance
>  Sticky



-- 
Puneet Kishor http://www.punkish.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to