I have a working query:

/* start */

SELECT 
u.user_id, 
u.first_name AS u_first_name, 
u.last_name AS u_last_name, 
c.client_id AS c_client_id, 
c.first_name AS c_first_name, 
c.middle_name AS c_middle_name, 
c.last_name AS c_last_name, 
c.address AS c_address, 
c.city AS c_city, 
c.state AS c_state, 
c.zip AS c_zip, 
c.dob AS dob_ymd, 
c.phone_home AS c_phone_home, 
c.phone_cell AS c_phone_cell, 
c.phone_work AS c_phone_work, 
c.email AS c_email, 
c.other_contacts AS c_other_contacts, 
count(*) AS apt_qty

FROM tl_appt apt 

JOIN tl_clients c ON c.client_id = apt.client_id 
JOIN tl_rooms r ON r.room_id = apt.room_id 
JOIN tl_users u ON u.user_id = apt.user_id 

WHERE 1 AND apt.appt_status_id IN (16) AND apt.user_id IN (3) AND 
apt.time_start BETWEEN '1501560000' AND '1504238399' 
GROUP BY c.client_id 

HAVING count(*) > 0 

ORDER BY u.first_name, u.last_name, c.last_name, c.first_name;

/* end */

I want to add another condition:

Of these found rows, I want to omit those rows where there are rows found after 
the END TimeStamp based on below where clause:

 WHERE 1 AND apt.appt_status_id IN (16) AND apt.user_id IN (3) AND 
apt.time_start  > ‘1504238399'

We are trying to find Former Clients who have not been seen after the date 
range - Lapsed Client Report


Don Wieland
d...@pointmade.net
http://www.pointmade.net
https://www.facebook.com/pointmade.band




Reply via email to