Advertisement
Jgug

Requests_01

Dec 1st, 2014
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.52 KB | None | 0 0
  1. -- Количество договоров по годам
  2.  
  3. SELECT EXTRACT(YEAR FROM C.DATE_OF_CONTRACT) AS YEAR, COUNT(*) AS CONTRACTS
  4. FROM Contracts C
  5. GROUP BY EXTRACT(YEAR FROM C.DATE_OF_CONTRACT);
  6.  
  7. -- Количество договоров по месяцам текущего года
  8.  
  9. SELECT EXTRACT(MONTH FROM C.DATE_OF_CONTRACT) AS MONTH, COUNT(*) AS CONTRACTS
  10. FROM Contracts C
  11. WHERE EXTRACT(YEAR FROM C.DATE_OF_CONTRACT) = TO_CHAR(sysdate, 'YYYY')
  12. GROUP BY EXTRACT(MONTH FROM C.DATE_OF_CONTRACT)
  13. ORDER BY MONTH ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement