以下のクエリを使用すると、特定の日付範囲で実行されたサービスを監視できます。また、過去の「X」日を表示するように変更します。
これが私の問題です。ある日付範囲で活動がなかったすべてのクライアントを見つける必要があります。左外部結合 ( http://www.postgresqlforbeginners.com/2010/11/sql-outer-joins.html ) を使用する例を見て、それに従おうとしましたが、「欠落している」サービスは表示されませんでした。過去の「X」日間に「Bob」が表示されていないことを確認する必要がありました。実際に発生したアクティビティではありません。
だから、誰かがこれを見て解決策に導くことができれば、私はとても感謝しています
クエリは次のとおりです。
SELECT groups.name as Office,to_char (notes.date_service,'MM/DD/YY')as DateEntered,
to_char(notes.date_creation,'MM/DD/YY')as DateService,
notes.date_creation - notes.date_service as DateDiff,
services.code, clients.client_id,
clients.name_lastfirst_cs, staff.staff_name_cs, address.addr_county
FROM notes, services, clients, staff, groups, address
WHERE notes.zrud_service = services.zzud_service
AND notes.zrud_client = clients.zzud_client
AND notes.zrud_staff = staff.zzud_staff
AND notes.zrud_group = groups.zzud_group
AND clients.zzud_client = address.zrud_client
AND services.code IN ('10101', '10102', '10201' , '10202','10203','10204','10205','10401','10402','10403','10405') - - <I comment out this line and change it depending on the results I need >
AND groups.name = 'RCE'
AND notes.date_service BETWEEN (now() - '8 days'::interval)::timestamp AND now();
-- this last line is also changed for diferent time spans
ありがとう