sql - Find those who have NOT written a letter -


i have 3 tables: tblareas, describes various areas of uk; tblnewsletters, lists quarterly dates when publish newsletters; tblissues, many-to-many table linking previous two. tbl issues describes each newsletter produced each area in each quarter (one newsletter per area per quarter). want find areas have not produced newsletter in given quarter. make start, did not attempt restrict output particular quarter, couldn't work. here code:

select tblarea.id, tblarea.areaname     tblissues         not exists             (select newsletterlookup              tblissues              tblissues.arealookup = tblarea.id); 

select *  tblarea left join tblissues on i.areaid = a.id i.areaid null 

for specific quarter, have use subquery.

select *  tblarea left join (select areaid             tblissues ii            inner join newsletters n on n.id = ii.newsletterid            n.issuedate = #12/31/2015#            ) on i.areaid = a.id i.areaid null 

not tested..sorry


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -