Advertisement
kknndd_

PUTIN SECRET RECIPE FOR VODKA

Apr 26th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. https://www.postgresql.org/docs/9.1/functions-formatting.html
  2.  
  3. cv. 5
  4. 2.2
  5.  
  6. SELECT
  7.     invoicedate,
  8.     concat(
  9.         "billingaddress",
  10.         ' ',
  11.         "billingcity",
  12.         ', ',
  13.         "billingpostalcode"
  14.         ) as address
  15. FROM
  16.     invoice
  17. WHERE billingcountry = 'United Kingdom'
  18. AND DATE_PART('month', invoicedate) = '5'
  19. AND DATE_PART('year', invoicedate) = '2013';
  20.  
  21. 2.3
  22.  
  23. SELECT
  24.     "firstname",
  25.     "lastname",
  26.     to_char("birthdate", 'DD.MM.YY') as birthdate,
  27.     ROUND(EXTRACT('days' FROM ('2021-02-10' - "birthdate" ) ) / 365) as age
  28. FROM employee;
  29.  
  30. --
  31.  
  32. SELECT
  33.     COUNT(*) as albums_count
  34. FROM album
  35.     WHERE artistid = (
  36.         SELECT a.artistid FROM artist as a WHERE a.name = 'U2' LIMIT 1
  37.     )
  38. ;
  39.  
  40. --
  41.  
  42. SELECT
  43.     COUNT(*) as count,
  44.     a.name
  45. FROM album al
  46. INNER JOIN artist a on a.artistid = al.artistid
  47. GROUP BY (al.artistid), a.name
  48. ;
  49.  
  50. -----------------------------------------------------
  51. -----------------------------------------------------
  52. -----------------------------------------------------
  53.  
  54.  
  55. 6
  56.  
  57. 1.1
  58.  
  59. SELECT *
  60. FROM track
  61. WHERE mediatypeid = (
  62.     SELECT mediatypeid
  63.     FROM mediatype
  64.     WHERE name LIKE '%video%' LIMIT 1
  65. );
  66.  
  67. 1.2
  68.  
  69. SELECT
  70.     firstname,
  71.     lastname,
  72.     phone
  73. FROM customer
  74. WHERE supportrepid = (SELECT employeeid FROM employee WHERE firstname = 'Margaret' AND lastname = 'Park')
  75. ORDER BY lastname, firstname
  76. ;
  77.  
  78. 3.1
  79.  
  80. SELECT
  81.    name
  82. FROM artist
  83. LEFT OUTER JOIN album a on artist.artistid = a.artistid
  84. GROUP BY albumid, artist.name
  85. HAVING
  86.     COUNT(albumid) = 0;
  87.    
  88.    
  89. 3.2
  90.  
  91. SELECT
  92.     concat(
  93.         e.lastname, ' ', e.firstname
  94.         ) as zamestnanec,
  95.         case
  96.             when e.reportsto is null then concat( e.lastname, ' ', e.firstname )
  97.             else concat( em.lastname, ' ', em.firstname )
  98.         end
  99.         as nadriadeny
  100. FROM employee as e
  101. LEFT JOIN employee as em on em.employeeid = e.reportsto
  102. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement