Re: [SQL] return records with more than one occurrences

2011-01-07 Thread Russell Galyon
SELECT t.id t.id_table1 t.name FROM Table2 t INNER JOIN (SELECT t_inner.id_table1 FROM Table2 t_inner GROUP BY 1 HAVING COUNT(*) > 1) temp ON temp.id_table1 = t.id_table1 ; On Wed, Jan 5, 2011 at 8:18 AM, Tarsis Lima wrote: > how would the SELECT to return on

Re: [SQL] pattern matching with dates?

2011-01-07 Thread Richard Huxton
On 07/01/11 14:15, pasman pasmański wrote: Sorry, but this examples not use index. Looks like it does here (oh, and please try to post your replies at the bottom of the message) On 1/7/11, Susanne Ebrecht wrote: The more proper way is: SELECT * from tab WHERE EXTRACT(YEAR FROM log_da

Re: [SQL] pattern matching with dates?

2011-01-07 Thread pasman pasmański
Sorry, but this examples not use index. On 1/7/11, Susanne Ebrecht wrote: > Hello Thomas, > > On 05.01.2011 20:39, Good, Thomas wrote: >> select * from db_log where log_date LIKE '2011-01-%'; > > The lazy way would be something like this: > SELECT * from tab WHERE log_date::VARCHAR LIKE '2011-01-

Re: [SQL] pattern matching with dates?

2011-01-07 Thread Susanne Ebrecht
Hello Thomas, On 05.01.2011 20:39, Good, Thomas wrote: select * from db_log where log_date LIKE '2011-01-%'; The lazy way would be something like this: SELECT * from tab WHERE log_date::VARCHAR LIKE '2011-01-%'; The more proper way is: SELECT * from tab WHERE EXTRACT(YEAR FROM log_date) = 20

Re: [SQL] return records with more than one occurrences

2011-01-07 Thread Oliveiros d'Azevedo Cristina
Howdy, Tarsis. Please try this out. SELECT a.id, id_table1,a.name FROM "Table2" a NATURAL JOIN (SELECT id_table1 "Table2" GROUP BY id_table1 HAVING COUNT(*) > 1) b Tell me if it worked or not, and if it didn't the errors/uncorrect results. Best, Oliveiros - Original Message - From

Re: [SQL] pattern matching with dates?

2011-01-07 Thread Samuel Gendler
On Wed, Jan 5, 2011 at 11:39 AM, Good, Thomas wrote: > This dubious query worked well previously: > select * from db_log where log_date LIKE '2011-01-%'; > (currently works on bluehost.com where they run 8.1.22) > > Can someone offer a (preferably ANSI compliant) way to do this on 8.4.5? > > I re

Re: [SQL] return records with more than one occurrences

2011-01-07 Thread Jasmin Dizdarevic
Hi, this is a good point to start. select t2.* from table2 t2 inner join ( select id from table1 group by id having count(*) > 1 ) t1 on t2.id_table1 = t1.id 2011/1/5 Tarsis Lima > how would the SELECT to return only records with more than one > occurrences of id_table1? example: > --