Re: [GENERAL] Special ORDER BY

2012-06-19 Thread Hellmuth Vargas
Helo This is provided that the list is constant SELECT * FROM subcampo sc JOIN campo c ON (c.codigo = sc.campo) JOIN (values(245,1),(130,2), (240,3), (243,4), (246,5), (490,6), (630,7), (730,8), (740,9)) as d(dato,orden) on (c.etiqueta =d.dato) ORDRE BY d.orden On Tue, Jun 19, 2012 a

Re: [GENERAL] Special ORDER BY

2012-06-19 Thread Tulio
You can use something like "CASE WHEN" .. and use a number to order your data... like this SELECT *, CASE WHEN c.etiqueta = 245 THEN 1 WHEN c.etiqueta = 130 THEN 2 WHEN c.etiqueta = 240 THEN 3 WHEN c.etiqueta = 243 THEN 4 WHEN c.etiqueta = 246 THEN 5 WHEN c.eti

[GENERAL] Special ORDER BY

2012-06-19 Thread Martín Marqués
How can I order a result set by a special order of a column. For example, let's say I have this query SELECT * FROM subcampo sc JOIN campo c ON (c.codigo = sc.campo) WHERE c.etiqueta IN (245, 130, 240, 243, 246, 490, 630, 730, 740) Now I want to order the result set using c.etiqueta but wi