Re: [GENERAL] Need Help in query

2010-12-23 Thread Satish Burnwal (sburnwal)
Thanks! I did not know such a function exists. From: Nicklas Avén [mailto:nicklas.a...@jordogskog.no] Sent: Thursday, December 23, 2010 3:31 PM To: Satish Burnwal (sburnwal) Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Need Help in query Hallo This I think should work. To get

Re: [GENERAL] Need Help in query

2010-12-23 Thread Nicklas Avén
Hallo This I think should work. To get the usernames by hour as you describe: SELECT h.hour, usrlog.userid (select generate_series(1,24) as hour) as h inner join usrlog on h.hour >= usrlog.loginhr and h.hour <= usrlog.logouthr order by h.hour, usrlog.userid; To get the number of users per hour

[GENERAL] Need Help in query

2010-12-23 Thread Satish Burnwal (sburnwal)
I need a help in writing a query. I have data as follows: mydb=# select * from usrlog ; logid | userid | loginhr | logouthr ---+--+-+-- 0 | sburnwal | 0 |1 1 | rickyrs | 1 |5 2 | satishbn | 1 |6 3 | tao