Re: Why this query does not work?

Поиск
Список
Период
Сортировка
От A.Bhuvaneswaran
Тема Re: Why this query does not work?
Дата
Msg-id Pine.LNX.4.44.0305131338400.9559-100000@Bhuvan.bksys.co.in
обсуждение исходный текст
Ответ на Why this query does not work?  ("Katka a Daniel Dunajsky" <daniel_katka@hotmail.com>)
Список pgsql-sql
> service0=#
> service0=# SELECT DISTINCT machine_id
> service0-# FROM                   user_sessions
> service0-# WHERE                 TO_CHAR(session_start, 'Month') = 'April';
> 
> machine_id
> ------------
> (0 rows)
> 

Since to_char function pads space to the value returned. The length of the 
return value of to_char function is 9. It is mentioned in the document, 
please refer the below link for details:

http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=functions-formatting.html

You can use rtrim to get rid of your problem. 

=> select distinct machine_id from user_sessions where rtrim (to_char
(session_start, 'Month')) = 'April';

regards,
bhuvaneswaran



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why this query does not work?
Следующее
От: "Ryan"
Дата:
Сообщение: N all-way relationship