DISTINCT with NULLs and INT fields

Поиск
Список
Период
Сортировка
От George Pavlov
Тема DISTINCT with NULLs and INT fields
Дата
Msg-id CCB89282FCE1024EA3DCE687A96A5164039EC532@ehost010-6.exch010.intermedia.net
обсуждение исходный текст
Ответы Re: DISTINCT with NULLs and INT fields  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
What does The SQL Standard say about this one?

create table foo (a varchar, b int);

insert into foo (a, b) select null, null from bar;
-- no problem

insert into foo (a, b) select distinct null, null from bar;
-- ERROR:  column "b" is of type integer but expression is of type text
-- HINT:  You will need to rewrite or cast the expression.

It seems that applying DISTINCT makes the NULL be of type TEXT... I just
tried the exact same thing in Ms. SQL Server 2005 and it works with no
errors. Looks like SQL Server makes the NULLs be INTs, but is probably
better at doing the implicit conversion from INT. Any thoughts on what
the "correct" behavior should be here?

George


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

Предыдущее
От: Don Croata
Дата:
Сообщение: Re: Cursors and recursion
Следующее
От: Tom Lane
Дата:
Сообщение: Re: DISTINCT with NULLs and INT fields