Tag Info

New answers tagged

0

Another way: WITH StatusChanges AS ( SELECT HistoryID,PartID,Status, DateAdded, rnAsset = ROW_NUMBER() OVER (PARTITION BY PartID ORDER BY DateAdded) FROM aAssetHistory ) SELECT X.SerialNumber, X.PartNumber, X.ProjectName, X.ProjectNumber, X.AssetDescription, X.Available, X.Location, X.LocStatus, X.AssetComment, X.Disposition, X.Fund, ...


0

WITH StatusChanges AS ( SELECT HistoryID,PartID,Status, DateAdded, rnAsset = ROW_NUMBER() OVER (PARTITION BY PartID ORDER BY DateAdded) FROM aAssetHistory ) SELECT A.isMarketed,A.AssetDescription,A.aPartID,A.SerialNumber,A.PartNumber, A.Location,A.Vintage,Ap.Fund,A.ProjectNumber,AP.ProjectName , ( SELECT Top 1 ...


2

If I'm understanding you correctly what you're looking to do should be quite simple. I'm not entirely sure how you're setting @date1 but for this to work you will need to set that as a SSIS variable and for this example I'll assum it's a date. Then you need to create your query as a variable and then set it as an expression like so. Then you set your ...


0

If your manager column is an INT type, it'll probably be NULL or 0 when it has no manager assigned. WITH emp_hier AS ( SELECT BOSS.employee_number, BOSS.name, BOSS.manager, 0 as empLevel FROM Employees as BOSS WHERE BOSS.manager is null UNION ALL SELECT emp.employee_number, emp.name, emp.manager, e.empLevel + 1 FROM Employees as emp INNER ...


2

It's not possible to bind column names to variables, but you can achieve similar results by using dynamic SQL. DECLARE @datetxt varchar(10) = '2015-01-01' DECLARE @sqltxt nvarchar(1000); SET @sqltxt = N'SELECT dateAdd(second, 1, ' + @datetxt + ') AS StartTime FROM Termination_Call_Detail' Exec (@sqltxt)


2

As the discussion in the comments revealed, an fcontainer can be related to many products, due to the 1-to-many relationship between FContainer and Stämplingar. Try this query, which will choose only one product per fcontainer. The missing fcontainers are due to the INNER join. Changing it to LEFT join will show all fcontainers, even those not related to ...



Top 50 recent answers are included