Combining 3 tables in the same database: The 3 tables under the same database called Files - the table names im interested in are RXInboundFileQueue, EligibilityFileQueue, and CostFileQueue. All 3 tables share the OriginalName and FileCatalogedOn columns. For an output I'm looking for a query that combines all 3 tables into 1 view and displays each tables files listed within the last 7 days. The code below I wrote outputs every file from each table starting from todays date - but I can't figure a good way to write an outer join to merge these results and only look at a 7 day look behind.
DECLARE @DateFrom DateTime = (SELECT CAST(GetDate() as Date))
DECLARE @DateTo DateTime = (SELECT DATEADD(DAY, 1, @DateFrom))
SELECT
OriginalName,
FileCatalogedOn
FROM RXInboundFileQueue
ORDER BY FileCatalogedOn DESC
DECLARE @DateFrom DateTime = (SELECT CAST(GetDate() as Date))
DECLARE @DateTo DateTime = (SELECT DATEADD(DAY, 1, @DateFrom))
SELECT
OriginalName,
FileCatalogedOn
FROM EligibilityInboundFileQueue
ORDER BY FileCatalogedOn DESC
DECLARE @DateFrom DateTime = (SELECT CAST(GetDate() as Date))
DECLARE @DateTo DateTime = (SELECT DATEADD(DAY, 1, @DateFrom))
SELECT
OriginalName,
FileCatalogedOn
FROM CostFileInboundFileQueue
ORDER BY FileCatalogedOn DESC