Advertisement
JellyKuo

SQL 45th View

Apr 10th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.48 KB | None | 0 0
  1. SELECT D.Contents, D.CountOfUsed, CAST(CAST(D.CountOfUsed AS FLOAT) / P.Ratio AS NUMERIC(4, 3)) AS Ratio
  2. FROM (SELECT COUNT(*) AS Ratio
  3.     FROM [dbo].[CheckInRecord]
  4.     WHERE (dbo.CheckInRecord.Payment IS NOT NULL))
  5.     AS P
  6. CROSS JOIN  (SELECT STATUS.Contents, COUNT(STATUS.Contents) AS CountOfUsed
  7.     FROM dbo.STATUS
  8.     RIGHT OUTER JOIN dbo.CheckInRecord ON STATUS.STATUS = CheckInRecord.Payment
  9.     WHERE (STATUS.Item = 'Payment')
  10.     GROUP BY STATUS.Contents)
  11.     AS D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement