ORDER BY - problem with NULL values

Поиск
Список
Период
Сортировка
От Stefan Schwarzer
Тема ORDER BY - problem with NULL values
Дата
Msg-id 2D692754-C61D-49FB-A384-7E6DEE89C9CF@grid.unep.ch
обсуждение исходный текст
Ответы Re: ORDER BY - problem with NULL values  (Richard Huxton <dev@archonet.com>)
Re: ORDER BY - problem with NULL values  (Tommy Gildseth <tommy.gildseth@usit.uio.no>)
Список pgsql-general
Hi there,

if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered correctly.

Is there any way to 

   a) make the countries with NULL values appear at the bottom of the list
   b) neglect the NULL values by still allowing the countries to be displayed

?

My SQL looks like this:

SELECT 
SUM(CASE WHEN year=2002 THEN value ELSE NULL END) AS "y_2002", 
SUM(CASE WHEN year=2001 THEN value ELSE NULL END) AS "y_2001", 
SUM(CASE WHEN year=2000 THEN value ELSE NULL END) AS "y_2000", 
c.name AS name 
FROM 
aquacult_prod_marine AS d 
LEFT JOIN 
countries AS c ON c.id = id_country 
GROUP BY 
name 
ORDER BY 
y_2000 DESC

Thanks for any info...

Stef

 ____________________________________________________________________

  

  Stefan Schwarzer
  
  Lean Back and Relax - Enjoy some Nature Photography: 
  
  Appetite for Global Data? UNEP GEO Data Portal:  
  ____________________________________________________________________





В списке pgsql-general по дате отправления:

Предыдущее
От: "Jasbinder Singh Bali"
Дата:
Сообщение: Re: SLEEP in posgresql
Следующее
От: Ow Mun Heng
Дата:
Сообщение: Re: replacing single quotes