/*
Here we are basically just doing SELECT * FROM VariableValue WHERE VariableID = 57
The reason we are doing all the join statements is we are trying to target only the files in the
DWS folder, so we need the other tables in order to construct a path
*/

SELECT
	v.VariableID,
    v.DocumentID,
    v.ProjectID,
    v.RevisionNo,
    v.ConfigurationID,
    v.ValueText,
    v.ValueInt,
    v.ValueFloat,
    v.ValueDate,
    v.ValueCache,
    v.IsLongText
FROM [Drilling_Test].[dbo].[Documents] d
INNER JOIN [Drilling_Test].[dbo].[DocumentsInProjects] dp on d.[DocumentID] = dp.DocumentID 
INNER JOIN [Drilling_Test].[dbo].[Projects] p on dp.ProjectID = p.ProjectID
INNER JOIN [Drilling_Test].[dbo].[VariableValue] v on d.DocumentID = v.DocumentID
WHERE v.VariableID = 57 and p.Path like '%DWS%'
ORDER BY v.DocumentID asc;
