I would like to send a flyer to all patients who have no balance and who have been seen within the last six months.
The following query specifies only that the patient has been seen for some sort of service in the last 180 days and that the current balance is zero or less.
Check the appropriate How-To document in the blue bar at the top of the page for instructions on saving the results to HTML format that you can open and save with Excel. You can then use the Mail-Merge feature in MS Word to create your labels using this data. See Mail Merge Labels in Word Using Query Results.
SELECT
(a.firstname + ' '+a.lastname) AS "name",
a.addr1 AS "addr1",
a.addr2 AS "addr2",
(a.city+', '+a.state+' '+a.zip) AS "addr3"
FROM
sos.rv_patients a
JOIN sos.pt_noninsbalance b ON a.ptnum = b.ptnum
WHERE
b.ptbalance <= 0
AND lfeedate > (TODAY()-180)
; OUTPUT TO c:\sos\labels.html FORMAT HTML
