[SQL] all the table values equal

2010-09-17 Thread Michele Petrazzo - Unipex
Hi list, this is a Friday afternoon question... :) I have a table like this: id_user | value | datetime 1 | 1 | xxx 1 | 2 | xxx+1 1 | -1 | xxx+2 2 | -1 | xxx 2 | -1 | xxx+1 3 | 4 | xxx 3 | 10 | xxx+1 I'm trying to create a query that say me which id_user, inside a interval of time, has all the v

Re: [SQL] all the table values equal

2010-09-17 Thread Oliveiros d'Azevedo Cristina
Howdy , Michele, Give this a try SELECT id_user FROM t_your_table WHERE datetime BETWEEN A -- plug here beginning of interval AND B-- and end here GROUP BY id_user HAVING COUNT(*) = -SUM(value) Then tell me if it gives you what you want Best, Oliveiros Cristina - Original Message

Re: [SQL] all the table values equal

2010-09-17 Thread Michele Petrazzo - Unipex
Oliveiros d'Azevedo Cristina ha scritto: Howdy , Michele, Give this a try SELECT id_user FROM t_your_table WHERE datetime BETWEEN A -- plug here beginning of interval AND B -- and end here GROUP BY id_user HAVING COUNT(*) = -SUM(value) Then tell me if it gives you what you want Thanks, it w