Re: [firebird-support] SQL puzzle: Order based on Prerequisite

2015-04-11 Thread liviusliv...@poczta.onet.pl [firebird-support]
Hi, or better for “The SQL may return one or more records with a blank B4Me. In which case, Natural order can be used for those records, and they are all considered First or rather, Before everything else” select CASE WHEN B4ME IS NULL THEN 0 ELSE 1 END, CASE WHEN B4ME IS NULL THEN ID ELSE

Re: [firebird-support] SQL puzzle: Order based on Prerequisite

2015-04-11 Thread liviusliv...@poczta.onet.pl [firebird-support]
Hi, you must rethink what you try to retrive. What is then sense of returning somethink in case of cycles? If you have cycles then you do not get something before.. But if you need something strange then it is simple ID as integer select CASE WHEN B4ME IS NULL THEN ID ELSE B4ME+1 END,