instead of
> SELECT name, (CASE WHEN bar = 34 THEN 0 ELSE 1 END) AS rank> FROM foo> WHERE
> bar = 34> OR baz > 100> ORDER BY rank ASC, baz DESC> LIMIT 5;
you can use order the query evaluation to perform inner subquery first
select distinct foo.name,foo.bar,baz.bar from foo where exists (selec
On Nov 30, 2008, at 11:42 PM, Andy Shellam wrote:
Hi Morten,
I think this is valid in MySQL (it certainly is for SQL Server) but
you can use a CASE statement directly in the ORDER BY clause. Try
something like this:
SELECT name
FROM foo
WHERE bar = 34
OR baz > 100
ORDER BY CASE ba
Hi Morten,
I think this is valid in MySQL (it certainly is for SQL Server) but you
can use a CASE statement directly in the ORDER BY clause. Try something
like this:
SELECT name
FROM foo
WHERE bar = 34
OR baz > 100
ORDER BY CASE bar WHEN 34 THEN 0 ELSE 1 END ASC, baz DESC
LIMIT 5;
Re