Advertisement
kyamaliev

Lab - Problem 10

Feb 26th, 2015
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.44 KB | None | 0 0
  1. SELECT a.Content as [Answer Content], q.Title as Question, c.Name as Category
  2. FROM Answers a
  3. JOIN Questions q ON q.Id = a.QuestionId
  4. JOIN Categories c ON c.Id = q.CategoryId
  5. WHERE
  6.     YEAR(a.CreatedOn) = (SELECT MAX(YEAR(a.CreatedOn)) FROM Answers a)
  7.     AND
  8.     a.IsHidden = '1'
  9.     AND
  10.     (MONTH(a.CreatedOn) = (SELECT MIN(MONTH(a.CreatedOn)) FROM Answers a)
  11.     OR
  12.     MONTH(a.CreatedOn) = (SELECT MAX(MONTH(a.CreatedOn)) FROM Answers a))
  13. ORDER BY c.Name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement