F
FJB
I have two queries that I need help with which deal with differences
between dates. First, the difference between the value in a field and
the system date resulting in a number of days difference sorted
descending. Second, the difference between the value of two fields
resulting in a number of days. Below are the SQL views of the current
queries which need to be modified. Thanks for your help
Frank
Query 1
SELECT dbo_TBLCASE.CASEID, dbo_TBLCASE.OPENDATE,
dbo_TBLCASE.INVESTIGATORNAME, dbo_TBLCASE.CASECLOSINGNOTES
FROM dbo_LTBSARCHARACTERIZATION1, (dbo_TBLCASE INNER JOIN
dbo_LTBCATEGORY1 ON dbo_TBLCASE.CATEGORYID=dbo_LTBCATEGORY1.CATEGORYID)
INNER JOIN dbo_ITBINVESTIGATOR1 ON
dbo_TBLCASE.INVESTIGATORID=dbo_ITBINVESTIGATOR1.INVESTIGATORID
WHERE (((dbo_TBLCASE.STATUS)="OPN") AND
((dbo_LTBSARCHARACTERIZATION1.DESCRIPTION)="Bank Secrecy
Act/Structuring/Money Laundering") AND
((dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32453 Or
(dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32454 Or
(dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32455 Or
(dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32431));
Query 2
SELECT [SAR Filings].[AMLOC Decision Date], [SAR Filings].[AMLOC
Decision], [SAR Filings].[AMLOC?], [SAR Filings].[Early AMLOC], [SAR
Filings].[Relationship Name], [SAR Filings].[Client Number], [SAR
Filings].[ICMS Case Number], [SAR Filings].[FIU Investigator], [SAR
Filings].[SSN/TIN], [SAR Filings].[Account Number], [SAR Filings].[To
Close By], [SAR Filings].[Number of SARs filed], [SAR Filings].LOB,
[SAR Filings].[Other LOB Relationships], [SAR Filings].[Reporting
Region], [SAR Filings].[SAR Filed Date], [SAR Filings].[Previous SAR
Date 1], [SAR Filings].[Previous SAR Date 2], [SAR Filings].[Case
Category], [SAR Filings].[Case Category 2], [SAR Filings].Rank, [SAR
Filings].[Risk Level], [SAR Filings].[Risk Category], [SAR
Filings].Occupation, [SAR Filings].Employer, [SAR Filings].Comments,
[SAR Filings].[LE Letter], [SAR Filings].Employee, Group_Region.Group,
Group_Region.[Region Name], [SAR Filings].[Cost Center], [SAR
Filings].[Current Relationship Status], [STI Branch Listing-OLD].NAME,
[STI Branch Listing-OLD].CITY, [STI Branch Listing-OLD].STATE, [SAR
Filings].[Prior SAR Category #1], [SAR Filings].[Prior SAR Category
#2], [SAR Filings].[Current Relationship Status], [SAR
Filings].Description, [SAR Filings].[Date Account Opened]
FROM (Group_Region INNER JOIN [SAR Filings] ON Group_Region.[Reporting
Region] = [SAR Filings].[Reporting Region]) INNER JOIN [STI Branch
Listing-OLD] ON [SAR Filings].[Cost Center] = [STI Branch
Listing-OLD].CC
WHERE ((([SAR Filings].[AMLOC Decision Date]) Is Not Null) AND (([SAR
Filings].[AMLOC?])=Yes) AND (([SAR Filings].[To Close By]) Is Null)) OR
((([SAR Filings].[AMLOC Decision Date]) Is Not Null) AND (([SAR
Filings].[Early AMLOC])=Yes))
ORDER BY [SAR Filings].[AMLOC Decision Date], [SAR
Filings].[Relationship Name];
between dates. First, the difference between the value in a field and
the system date resulting in a number of days difference sorted
descending. Second, the difference between the value of two fields
resulting in a number of days. Below are the SQL views of the current
queries which need to be modified. Thanks for your help
Frank
Query 1
SELECT dbo_TBLCASE.CASEID, dbo_TBLCASE.OPENDATE,
dbo_TBLCASE.INVESTIGATORNAME, dbo_TBLCASE.CASECLOSINGNOTES
FROM dbo_LTBSARCHARACTERIZATION1, (dbo_TBLCASE INNER JOIN
dbo_LTBCATEGORY1 ON dbo_TBLCASE.CATEGORYID=dbo_LTBCATEGORY1.CATEGORYID)
INNER JOIN dbo_ITBINVESTIGATOR1 ON
dbo_TBLCASE.INVESTIGATORID=dbo_ITBINVESTIGATOR1.INVESTIGATORID
WHERE (((dbo_TBLCASE.STATUS)="OPN") AND
((dbo_LTBSARCHARACTERIZATION1.DESCRIPTION)="Bank Secrecy
Act/Structuring/Money Laundering") AND
((dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32453 Or
(dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32454 Or
(dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32455 Or
(dbo_ITBINVESTIGATOR1.REGIONALMANAGERID)=32431));
Query 2
SELECT [SAR Filings].[AMLOC Decision Date], [SAR Filings].[AMLOC
Decision], [SAR Filings].[AMLOC?], [SAR Filings].[Early AMLOC], [SAR
Filings].[Relationship Name], [SAR Filings].[Client Number], [SAR
Filings].[ICMS Case Number], [SAR Filings].[FIU Investigator], [SAR
Filings].[SSN/TIN], [SAR Filings].[Account Number], [SAR Filings].[To
Close By], [SAR Filings].[Number of SARs filed], [SAR Filings].LOB,
[SAR Filings].[Other LOB Relationships], [SAR Filings].[Reporting
Region], [SAR Filings].[SAR Filed Date], [SAR Filings].[Previous SAR
Date 1], [SAR Filings].[Previous SAR Date 2], [SAR Filings].[Case
Category], [SAR Filings].[Case Category 2], [SAR Filings].Rank, [SAR
Filings].[Risk Level], [SAR Filings].[Risk Category], [SAR
Filings].Occupation, [SAR Filings].Employer, [SAR Filings].Comments,
[SAR Filings].[LE Letter], [SAR Filings].Employee, Group_Region.Group,
Group_Region.[Region Name], [SAR Filings].[Cost Center], [SAR
Filings].[Current Relationship Status], [STI Branch Listing-OLD].NAME,
[STI Branch Listing-OLD].CITY, [STI Branch Listing-OLD].STATE, [SAR
Filings].[Prior SAR Category #1], [SAR Filings].[Prior SAR Category
#2], [SAR Filings].[Current Relationship Status], [SAR
Filings].Description, [SAR Filings].[Date Account Opened]
FROM (Group_Region INNER JOIN [SAR Filings] ON Group_Region.[Reporting
Region] = [SAR Filings].[Reporting Region]) INNER JOIN [STI Branch
Listing-OLD] ON [SAR Filings].[Cost Center] = [STI Branch
Listing-OLD].CC
WHERE ((([SAR Filings].[AMLOC Decision Date]) Is Not Null) AND (([SAR
Filings].[AMLOC?])=Yes) AND (([SAR Filings].[To Close By]) Is Null)) OR
((([SAR Filings].[AMLOC Decision Date]) Is Not Null) AND (([SAR
Filings].[Early AMLOC])=Yes))
ORDER BY [SAR Filings].[AMLOC Decision Date], [SAR
Filings].[Relationship Name];