SHARE
TWEET

Untitled

Nam_Hoang_Waw Oct 8th, 2019 (edited) 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Question a */
  2. SELECT * FROM (SELECT * FROM [tableWarehouse] AS T LEFT JOIN [ItemType] AS I
  3. ON T.[ItemTypeID] = I.[ItemTypeID])
  4. ORDER BY [InTime] DESC;
  5.  
  6. /* Question b */
  7. SELECT COUNT (Warehouse.ItemIDType) AS [ID COUNT]
  8. FROM ItemType RIGHT JOIN Warehouse ON ItemType.ItemTypeID = Warehouse.ItemIDType
  9. WHERE (((ItemIDType) = 45) AND OutTime IS NULL)
  10. HAVING (DATEDIFF ('M', InTime, DATE()) >= 3);
  11.  
  12. /* Question c */
  13. SELECT MAX (DateDifference) AS [Max_Date]
  14. FROM (SELECT *,
  15. LAG (InTime, 1) OVER (ORDER BY InTime DESC) AS [DateDifference]
  16. FROM (SELECT Warehouse.InTime
  17. FROM Warehouse
  18. UNION
  19. SELECT Warehouse.OutTime
  20. FROM Warehouse
  21. ORDER BY InTime DESC);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top