Advertisement
blooming8

query auto

Apr 21st, 2022
890
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- 04/03/22 --
  2.  
  3. SELECT nome_modello, cod_modello
  4. from modelli
  5. where cod_fabbrica='001'
  6. order by nome_modello DESC;
  7.  
  8. select * from veicoli
  9. where cilindrata = 1590
  10. order by targa;
  11.  
  12. select * from veicoli
  13. where cilindrata > cavalli_fiscali * 20
  14. order by targa;
  15.  
  16. select * from veicoli
  17. where cilindrata > 1000 AND cod_combustibile = '01'
  18. order by targa;
  19.  
  20. select * from veicoli
  21. where cod_modello = '001' OR cod_modello = '004'
  22. order by targa;
  23.  
  24. select * from veicoli
  25. where NOT cod_categoria = '01'
  26. order by targa;
  27.  
  28. select * from veicoli
  29. where not (cod_categoria = '01' and cilindrata > 1500)
  30. order by targa;
  31.  
  32. -- BETWEEN --
  33. select * from veicoli
  34. where cilindrata BETWEEN 1500 and 1800
  35. order by targa;
  36.  
  37. select * from veicoli
  38. where (cilindrata >= 1500) and (cilindrata <= 1800)
  39. order by targa;
  40.  
  41. -- IN --
  42. select * from veicoli
  43. where targa IN ('A123456X', 'D238765W', 'XF5789GY')
  44. order by targa;
  45.  
  46. -- LIKE --
  47. select * from veicoli
  48. where targa LIKE 'C%'
  49. order by targa;
  50.  
  51. select * from veicoli
  52. where targa like '%C%'
  53. order by targa;
  54.  
  55. -- Seleziono una determinata 'c' --
  56. select * from veicoli
  57. where targa like '_______C';
  58.  
  59. -- IS --
  60. select * from veicoli
  61. where cilindrata IS NULL
  62. order by targa;
  63.  
  64. select * from veicoli
  65. where cilindrata not between 1500 and 1800
  66. order by targa;
  67.  
  68. select * from veicoli
  69. where targa not in ('A123456X', 'D238765W', 'XF5789GY')
  70. order by targa;
  71.  
  72. -- VALORE MAX & MIN --
  73. select
  74.     MAX(cilindrata) as "Cilindrata massima",
  75.     MIN(cilindrata) as "Cilindrata minima"
  76. from veicoli;
  77.  
  78. -- SOMMA --
  79. select SUM(cilindrata) as "Somma delle cilindrate"
  80. from veicoli;
  81.  
  82. -- MEDIA --
  83. select AVG(cilindrata) as "Media delle cilindrate"
  84. from veicoli;
  85.  
  86. -- DEVIAZIONE STANDARD & VARIANZA --
  87. select
  88.     STDDEV(cilindrata) as "Deviazione standard cilindrate",
  89.     VARIANCE(cilindrata) as "Varianza cilindrate"
  90. from veicoli;
  91.  
  92. -- ARROTONDAMENTO (2 CIFRE DECIMALI DOPO LA VIRGOLA) --
  93. select
  94.     ROUND(stddev(cilindrata), 2) as "Deviazione standard cilindrate",
  95.     ROUND(variance(cilindrata), 2) as "Varianza cilindrate"
  96. from veicoli;
  97.  
  98. --  CONTA OCCORRENZE --
  99. select COUNT(*) as "Numero veicoli" from veicoli;
  100. select count(cavalli_fiscali) as "Numero cavalli fiscali" from veicoli;
  101.  
  102. -- ALL (ANCHE LE OCCORRENZE UGUALI) --
  103. select count(all cavalli_fiscali) as "CF [anche uguali]" from veicoli;
  104.  
  105. -- DISTINCT --
  106. select count(distinct cavalli_fiscali) "CF [distinti]" from veicoli;
  107.  
  108.  
Advertisement
RAW Paste Data Copied
Advertisement