Re: [SQL] group by range of values

2007-07-27 Thread Michael Glaesemann
2007/7/27, Carol Cheung <[EMAIL PROTECTED]>: db=# select * from tester order by birth_year; birth_year | salary + 1946 | 78000 1949 | 61000 What is the data type of the birth_year column? I'd suggest using date if you can, as what it is is a date with

Re: [SQL] group by range of values

2007-07-27 Thread Rodrigo De León
On 7/27/07, I wrote: > On 7/27/07, Carol Cheung <[EMAIL PROTECTED]> wrote: > > Something like: > > > > decade | average(salary) > > ---+- > >1940 | 69500 > >1950 | 5.33 > >1960 | 53000 > >1970 | 40333.33 > > CREATE TABLE tester ( > birth_year integer, >

Re: [SQL] group by range of values

2007-07-27 Thread Pavel Stehule
Hello you can use CASE like SELECT CASE WHEN birth_year BETWEEN 1940 AND 1949 THEN 1940 WHEN birth_year BETWEEN 1950 AND 1959 THEN 1950 WHEN birth_year BETWEEN 1960 AND 1969 THEN 1960 WHEN birth_year BETWEEN 1970 AND 1979 THEN 1979 END, AVG(salary) FROM tester GROUP BY 1 ORDER BY 1; R

Re: [SQL] group by range of values

2007-07-27 Thread Rodrigo De León
On 7/27/07, Carol Cheung <[EMAIL PROTECTED]> wrote: > Something like: > > decade | average(salary) > ---+- >1940 | 69500 >1950 | 5.33 >1960 | 53000 >1970 | 40333.33 CREATE TABLE tester ( birth_year integer, salary numeric(10,2) ); SELECT SUBSTRING(T

Re: [SQL] group by range of values

2007-07-27 Thread Jon Sime
Carol Cheung wrote: Hello, Here's my table: db=# select * from tester order by birth_year; birth_year | salary + 1946 | 78000 1949 | 61000 1951 | 58000 1953 | 56000 1958 | 52000 1962 | 5 1965 | 45000 1967 |

[SQL] group by range of values

2007-07-27 Thread Carol Cheung
Hello, Here's my table: db=# select * from tester order by birth_year; birth_year | salary + 1946 | 78000 1949 | 61000 1951 | 58000 1953 | 56000 1958 | 52000 1962 | 5 1965 | 45000 1967 | 6 1968 |

Re: [SQL] problem join

2007-07-27 Thread Osvaldo Rosario Kussama
chester c young escreveu: having problem joining these correctly: schedule - cal_id references calendar not null - usr_id references users not null = unique( calZ_id, usr_id ) - result_no not null activity - cal_id references calendar not null - usr_id references users not null = unique( cal_id

Re: [SQL] strange result for select * from table where id=random()*900

2007-07-27 Thread Kristo Kaiv
On 27.07.2007, at 10:48, Stefan Zweig wrote: hi list, this is my query: select * from _g2977 where id=floor(random() * (900)); in table _g2977 i have id(s) from 1 up to 900. i just want to select one random dataset by the above query but i does not work. actually i get sometime zero, som

Re: [SQL] calling webservice through postgresql function

2007-07-27 Thread Dmitry Turin
Good day, Jyoti. JS> we can use any of the "untrusted" procedural languages JS> http://www.pgsql.cz/index.php/PL/Perlu_-_Untrusted_Perl_(en) What !! There is no need to have CREATE OR REPLACE FUNCTION open FILE, $_[0]; my @cntn = (); while () { } __You as man (by hands) convert__ tr

Re: [SQL] strange result for select * from table where id=random()*900

2007-07-27 Thread Achilleas Mantzios
Στις Παρασκευή 27 Ιούλιος 2007 10:48, ο/η Stefan Zweig έγραψε: > hi list, > > this is my query: > > select > * > from _g2977 > where > id=floor(random() * (900)); > > in table _g2977 i have id(s) from 1 up to 900. i just want to select one > random dataset by the above query but i does not work. >

Re: [SQL] strange result for select * from table where id=random()*900

2007-07-27 Thread Tommy Gildseth
On 07/27/2007 09:48 AM, Stefan Zweig wrote: hi list, this is my query: select * from _g2977 where id=floor(random() * (900)); in table _g2977 i have id(s) from 1 up to 900. i just want to select one random dataset by the above query but i does not work. actually i get sometime zero, some

[SQL] strange result for select * from table where id=random()*900

2007-07-27 Thread Stefan Zweig
hi list, this is my query: select * from _g2977 where id=floor(random() * (900)); in table _g2977 i have id(s) from 1 up to 900. i just want to select one random dataset by the above query but i does not work. actually i get sometime zero, sometimes one, sometimes two and sometimes even th