List:General Discussion« Previous MessageNext Message »
From:hsv Date:May 28 2012 9:49pm
Subject:Re: Query help...
View as plain text  
>>>> 2012/05/28 08:03 -0700, Don Wieland >>>>
Any assistance would be appreciated. Thanks!
<<<<<<<<

Maybe something like this:


SELECT usie.client_id, first_name, last_name, COUNT(anie.client_id)

FROM
(SELECT client_id, first_name, last_name, time_start
FROM tl_appt
JOIN tl_rooms USING(room_id)
JOIN tl_clients USING(client_id)
JOIN tl_users on USING(user_id)

WHERE
	appt_id IS NOT NULL AND
	time_start between '1293858000' and '1325393999' AND
	location_id = '1' and
	appt_status_id IN (3) and
	user_id IN (506)

GROUP BY user_id, client_id) AS usie

LEFT JOIN

(SELECT client_id, time_start
FROM tl_appt
JOIN tl_rooms USING(room_id)
JOIN tl_clients USING(client_id)

WHERE
	appt_id IS NOT NULL AND
	location_id = '1' and
	appt_status_id IN (3)) AS anie

ON usie.client_id = anie.client_id AND usie.time_start > anie.time_start
GROUP BY usie.client_id

**************************************************************
Scanned by  MailScan AntiVirus and Content Security Software.
Visit http://www.escanav.com for more info on eScan and X-Spam.
**************************************************************


Thread
Query help...Don Wieland28 May
  • Re: Query help...hsv28 May