Re: Omit another where clause from original query

2017-09-20 Thread Hal.sz S.ndor

2017/09/19 17:19 ... Don Wieland:

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


What are you getting that you want not to see? Certainly if you simply 
left off the upper half of the 'BETWEEN' you would get all those that 
you now get and all that have been left out by being dated over 
‘1504238399'.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Omit another where clause from original query

2017-09-19 Thread Don Wieland
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 '150156' 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