Topic: Cyclic request from several identical bases
Hello, prompt how to implement in following request a cycle.
Every day new basis Statistics_20170901, Statistics_20170902, Statistics_20170903 etc. is formed
It is necessary to update request where the data from new basis every day is added.
U.Name as [Gos. Number]
,S01.TotalKm as [Run (on September, 1st)]
,S02.TotalKm as [Run (on September, 2nd)]
,S03.TotalKm as [Run (on September, 3rd)]
,S04.TotalKm as [Run (on September, 4th)]
from Statistics_20170901.dbo. Units as U
LEFT JOIN Statistics_20170901.dbo. UnitStatistics as S01 ON (U.ID=S01.UnitId)
INNER JOIN Statistics_20170902.dbo. UnitStatistics as S02 ON (U.ID=S02.UnitId)
INNER JOIN Statistics_20170903.dbo. UnitStatistics as S03 ON (U.ID=S03.UnitId)
INNER JOIN Statistics_20170904.dbo. UnitStatistics as S04 ON (U.ID=S04.UnitId)
Whether it is possible to implement request with a following condition? To try bases with a title from Statistics_20170901 to Statistics_20170930 and if the necessary basis it is not created yet to pass it in request without an error.