Re: [SQL] help needs in converting db2 function in postgresql.

2011-01-12 Thread Amar Dhole
Thanks this solves my problem.. From: filip.rembialkow...@gmail.com [mailto:filip.rembialkow...@gmail.com] On Behalf Of Filip Rembialkowski Sent: Wednesday, January 12, 2011 1:41 AM To: Amar Dhole Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] help needs in

[SQL] Implement PostgreSQL full text search

2011-01-12 Thread -
Hello everyone. I'm trying to create search with pagination and filters on a website. I stumbled with the search for the words. It could do with ILIKE but the table will have many records, was looking at PostgreSQL full text search, but do not quite understand how to implement. Someone could help

[SQL] INSERT/UPDATE .. RETURNING

2011-01-12 Thread Protasov Vladimir
Hello everybody, I have the table (named for example mytable) and trigger on insert. The trigger do the following (in real trigger the logic is more complicated, but there is no difference for this question): INSERT INTO another_table VALUES (NEW.*); RETURN NULL; And i want to do the

[SQL] joining one record according to max value

2011-01-12 Thread George Francis
The following sql is intended to produce a list of all unique SOURCEs, along with the corresponding LEVEL.NAME for LEVEL with highest SCORE value via SOURCELEVEL. I'd like to know why it doesn't return a SCORE value for SOURCE with id 3, despite there being a SOURCELEVEL entry for it. Many

Re: [SQL] joining one record according to max value

2011-01-12 Thread George Francis
hmm, but if I try to constrain the inner query to the source_id of the outer query I get an error as follows: select source.source_id, score, name from source left join ( select * from sourcelevel, level where sourcelevel.level_id = level.level_id and sourcelevel.source_id = source.source_id

Re: [SQL] joining one record according to max value

2011-01-12 Thread Jasmin Dizdarevic
It's currently late, so excuse me if I'm wrong. Is this, what you like to have? select sl.source_id, max(score) from source s inner join sourcelevel sl on s.source_id = sl.source_id inner join level l on sl.level_id = l.level_id group by 1 This is the highest score per source_id. 2011/1/12

Re: [SQL] joining one record according to max value

2011-01-12 Thread George Francis
Close! but I need the name of the LEVEL with highest score, and I dont think I can get it this way. Thanks for trying though! On Wed, Jan 12, 2011 at 5:49 PM, Jasmin Dizdarevic jasmin.dizdare...@gmail.com wrote: It's currently late, so excuse me if I'm wrong. Is this, what you like to have?

Re: [SQL] joining one record according to max value

2011-01-12 Thread Jasmin Dizdarevic
There is probably a more elegant way, but this could help you. select i.source_id, nm.name, i.mxscore from ( select sl.source_id, max(score) mxscore from source s inner join sourcelevel sl on s.source_id = sl.source_id inner join level l on sl.level_id = l.level_id group by 1 ) i inner join (

Re: [SQL] joining one record according to max value

2011-01-12 Thread George Francis
thanks! I think this is the best answer I will get. On Wed, Jan 12, 2011 at 6:05 PM, Jasmin Dizdarevic jasmin.dizdare...@gmail.com wrote: There is probably a more elegant way, but this could help you. select i.source_id, nm.name, i.mxscore from ( select sl.source_id, max(score) mxscore