How about: SELECT e1.event_id, e1.time, count(distinct e2.time) FROM events e1 LEFT JOIN events e2 USING (event_id) GROUP BY e1.event_id, e1.time, e2.event_id HAVING count(e2.time_id) > 1 ;
I don't know if this one does it too (might work in strange MySQL SQL ;-) ) SELECT event_id, time FROM events GROUP BY event_id, time HAVING count(time) > 1 ; Mihail Manolov wrote: >:) Is this some sort of a joke? > >I am grouping using event_id, which makes your query useless because it will >return just the first time row per each event_id. > >Thanks anyway. I may have to use second query... :-( > > >Mihail > > >----- Original Message ----- >From: "Bhavin Vyas" <[EMAIL PROTECTED]> >To: "Mihail Manolov" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> >Sent: Thursday, July 11, 2002 10:51 PM >Subject: Re: Help - query suggestion needed - interesting case > > > > >>How about: >> >> SELECT >> event_id, time, >> count(DISTINCT time) AS Ranges >> FROM >> events >> GROUP BY >> event_id HAVING Ranges > 1 >> >> >>----- Original Message ----- >>From: "Mihail Manolov" <[EMAIL PROTECTED]> >>To: <[EMAIL PROTECTED]> >>Sent: Thursday, July 11, 2002 2:58 PM >>Subject: Help - query suggestion needed - interesting case >> >> >> >> >>>Greetings, >>> >>>I am stuck with this problem: >>> >>>I have the following table: >>> >>>event_id time >>>100 2000-10-23 >>>100 2000-10-23 >>>101 2000-10-24 >>>101 2000-10-25 >>> >>>I need to know all event_id's that have multiple times + time columns. >>> >>> >Is > > >>it >> >> >>>possible to get that result in just one query? >>>The result should be something like this: >>> >>>event_id time >>>101 2000-10-24 >>>101 2000-10-25 >>> >>> >>>I managed to get all event_id's that have multiple times, but I don't >>> >>> >know > > >>>how to get the time column in the same query. >>>Here is my current query: >>> >>>SELECT >>> event_id, >>> count(DISTINCT time) AS Ranges >>>FROM >>> events >>>GROUP BY >>> event_id HAVING Ranges > 1 >>> >>>Please help me to find a single query that will return the time column >>> >>> >as > > >>>well. >>> >>> >>>Mihail >>> >>> > > > >--------------------------------------------------------------------- >Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > >To request this thread, e-mail <[EMAIL PROTECTED]> >To unsubscribe, e-mail <[EMAIL PROTECTED]> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > -- Ralf Narozny SPLENDID Internet GmbH & Co KG Skandinaviendamm 212, 24109 Kiel, Germany fon: +49 431 660 97 0, fax: +49 431 660 97 20 mailto:[EMAIL PROTECTED], http://www.splendid.de --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php