pgsql age function showing 00:00:00 with year argument

Поиск
Список
Период
Сортировка
От Arup Rakshit
Тема pgsql age function showing 00:00:00 with year argument
Дата
Msg-id 1403508589.43836.YahooMailNeo@web193902.mail.sg3.yahoo.com
обсуждение исходный текст
Ответы Re: pgsql age function showing 00:00:00 with year argument
Список pgsql-general
Look the below 2 scenarios :-

yelloday-staging::YELLOW=> select id, dob from users;
 id |         dob         
----+---------------------
 13 | 
  9 | 1967-02-13 14:00:00
 10 | 
 11 | 
  8 | 1977-06-05 14:00:00
 15 | 
 21 | 
 14 | 2014-05-25 14:00:00
 37 | 
 22 | 
 26 | 2014-05-06 14:00:00
 32 | 
 35 | 
  7 | 
  6 | 2014-05-10 14:00:00
(15 rows)

yelloday-staging::YELLOW=> select date_trunc('year', age(dob)) as age, count(id) from users group by dob ;
   age    | count 
------------+-------
               |    10
 00:00:00 |     1
 47 years |     1
 00:00:00 |     1
 37 years |     1
 00:00:00 |     1
(6 rows)

Question -

(a) How to convert age to 1 year when age will come as 00:00:00 or calculate the age in years in with rounding like 0.4, 0.5, 47.3 years like that ?
(b) Why group by didn't group all '00:00:00' ?
 
Regards,
Arup Rakshit

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: How to get involved in the development of postgreSQL
Следующее
От: Oliver
Дата:
Сообщение: Re: Postgresql not getting assigned memory