queries.json 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. [
  2. {
  3. "name": "Sample: Salary Analysis",
  4. "desc": "Top salary 2007 above $100k, Salary growth (sorted) from 2007-08",
  5. "type": "2",
  6. "dialects": ["postgresql", "mysql", "presto"],
  7. "data": {
  8. "query": {
  9. "query": "SELECT sample_07.description, sample_07.salary\r\nFROM\r\n sample_07\r\nWHERE\r\n( sample_07.salary > 100000)\r\nORDER BY sample_07.salary DESC\r\nLIMIT 1000;\n\n\nSELECT s07.description, s07.salary, s08.salary,\r\n s08.salary - s07.salary\r\nFROM\r\n sample_07 s07 JOIN sample_08 s08\r\nON ( s07.code = s08.code)\r\nWHERE\r\n s07.salary < s08.salary\r\nORDER BY s08.salary-s07.salary DESC\r\nLIMIT 1000;\n\n\n",
  10. "type": 0,
  11. "email_notify": false,
  12. "is_parameterized": false,
  13. "database": "default"
  14. },
  15. "functions": [],
  16. "VERSION": "0.4.1",
  17. "file_resources": [],
  18. "settings": []
  19. }
  20. },
  21. {
  22. "name": "Sample: Top salary",
  23. "desc": "Top salary 2007 above $100k",
  24. "type": "0",
  25. "data": {
  26. "query": {
  27. "query": "SELECT sample_07.description, sample_07.salary\r\nFROM\r\n sample_07\r\nWHERE\r\n( sample_07.salary > 100000)\r\nORDER BY sample_07.salary DESC\r\nLIMIT 1000",
  28. "type": 0,
  29. "email_notify": false,
  30. "is_parameterized": false,
  31. "database": "default"
  32. },
  33. "functions": [],
  34. "VERSION": "0.4.1",
  35. "file_resources": [],
  36. "settings": []
  37. }
  38. },
  39. {
  40. "name": "Sample: Salary growth",
  41. "desc": "Salary growth (sorted) from 2007-08",
  42. "type": "0",
  43. "data": {
  44. "query": {
  45. "query": "SELECT s07.description, s07.salary, s08.salary,\r\n s08.salary - s07.salary\r\nFROM\r\n sample_07 s07 JOIN sample_08 s08\r\nON ( s07.code = s08.code)\r\nWHERE\r\n s07.salary < s08.salary\r\nORDER BY s08.salary-s07.salary DESC\r\nLIMIT 1000",
  46. "type": 0,
  47. "email_notify": false,
  48. "is_parameterized": false,
  49. "database": "default"
  50. },
  51. "functions": [],
  52. "VERSION": "0.4.1",
  53. "file_resources": [],
  54. "settings": []
  55. }
  56. },
  57. {
  58. "name": "Sample: Job loss",
  59. "desc": "Job loss among the top earners 2007-08",
  60. "type": "0",
  61. "data": {
  62. "query": {
  63. "query": "SELECT s07.description, s07.total_emp, s08.total_emp, s07.salary\r\nFROM\r\n sample_07 s07 JOIN \r\n sample_08 s08\r\nON ( s07.code = s08.code )\r\nWHERE\r\n( s07.total_emp > s08.total_emp\r\n AND s07.salary > 100000 )\r\nORDER BY s07.salary DESC\nLIMIT 1000",
  64. "type": 0,
  65. "email_notify": false,
  66. "is_parameterized": false,
  67. "database": "default"
  68. },
  69. "functions": [],
  70. "VERSION": "0.4.1",
  71. "file_resources": [],
  72. "settings": []
  73. }
  74. },
  75. {
  76. "name": "Sample: Customers",
  77. "desc": "Email Survey Opt-Ins, Customers for Shipping ZIP Code, Total Amount per Order",
  78. "type": "0",
  79. "data": {
  80. "query": {
  81. "query": "-- Get email survey opt-in values for all customers\nSELECT\r\n c.id,\r\n c.name,\r\n c.email_preferences.categories.surveys\r\nFROM customers c;\n\n\n\n-- Select customers for a given shipping ZIP Code\nSELECT\r\n customers.id,\r\n customers.name\r\nFROM customers\r\nWHERE customers.addresses['shipping'].zip_code = '76710';\n\n\n\n-- Compute total amount per order for all customers\nSELECT\r\n c.id AS customer_id,\r\n c.name AS customer_name,\r\n ords.order_id AS order_id,\r\n SUM(order_items.price * order_items.qty) AS total_amount\r\nFROM\r\n customers c\r\nLATERAL VIEW EXPLODE(c.orders) o AS ords\r\nLATERAL VIEW EXPLODE(ords.items) i AS order_items\r\nGROUP BY c.id, c.name, ords.order_id;",
  82. "type": 0,
  83. "email_notify": false,
  84. "is_parameterized": false,
  85. "database": "default"
  86. },
  87. "functions": [],
  88. "VERSION": "0.4.1",
  89. "file_resources": [],
  90. "settings": []
  91. }
  92. },
  93. {
  94. "name": "Sample: Top salary",
  95. "desc": "Top salary 2007 above $100k",
  96. "type": "1",
  97. "data": {
  98. "query": {
  99. "query": "SELECT sample_07.description, sample_07.salary\r\nFROM\r\n sample_07\r\nWHERE\r\n( sample_07.salary > 100000)\r\nORDER BY sample_07.salary DESC\r\nLIMIT 1000",
  100. "type": 1,
  101. "email_notify": false,
  102. "is_parameterized": false,
  103. "database": "default"
  104. },
  105. "functions": [],
  106. "VERSION": "0.4.1",
  107. "file_resources": [],
  108. "settings": []
  109. }
  110. },
  111. {
  112. "name": "Sample: Salary growth",
  113. "desc": "Salary growth (sorted) from 2007-08",
  114. "type": "1",
  115. "data": {
  116. "query": {
  117. "query": "SELECT s07.description, s07.salary, s08.salary,\r\n s08.salary - s07.salary\r\nFROM\r\n sample_07 s07 JOIN sample_08 s08\r\nON ( s07.code = s08.code)\r\nWHERE\r\n s07.salary < s08.salary\r\nORDER BY s08.salary-s07.salary DESC\r\nLIMIT 1000",
  118. "type": 1,
  119. "email_notify": false,
  120. "is_parameterized": false,
  121. "database": "default"
  122. },
  123. "functions": [],
  124. "VERSION": "0.4.1",
  125. "file_resources": [],
  126. "settings": []
  127. }
  128. },
  129. {
  130. "name": "Sample: Job loss",
  131. "desc": "Job loss among the top earners 2007-08",
  132. "type": "1",
  133. "data": {
  134. "query": {
  135. "query": "SELECT s07.description, s07.total_emp, s08.total_emp, s07.salary\r\nFROM\r\n sample_07 s07 JOIN \r\n sample_08 s08\r\nON ( s07.code = s08.code )\r\nWHERE\r\n( s07.total_emp > s08.total_emp\r\n AND s07.salary > 100000 )\r\nORDER BY s07.salary DESC\nLIMIT 1000",
  136. "type": 0,
  137. "email_notify": false,
  138. "is_parameterized": false,
  139. "database": "default"
  140. },
  141. "functions": [],
  142. "VERSION": "0.4.1",
  143. "file_resources": [],
  144. "settings": []
  145. }
  146. },
  147. {
  148. "name": "Sample: Customers",
  149. "desc": "Email Survey Opt-Ins, Customers for Shipping ZIP Code, Total Amount per Order",
  150. "type": "1",
  151. "data": {
  152. "query": {
  153. "query": "-- Get email survey opt-in values for all customers \nSELECT\r\n c.id,\r\n c.name,\r\n c.email_preferences.categories.surveys\r\nFROM customers c;\n\n\n\n-- Select customers for a given shipping ZIP Code\nSELECT\r\n c.id,\r\n c.name\r\nFROM customers c, c.addresses a\r\nWHERE a.key = 'shipping' and a.zip_code = '76710';\n\n\n\n-- Compute total amount per order for all customers\nSELECT\r\n c.id AS customer_id,\r\n c.name AS customer_name,\r\n o.order_id,\r\n v.total\r\nFROM\r\n customers c,\r\n c.orders o,\r\n (SELECT SUM(price * qty) total FROM o.items) v;",
  154. "type": 1,
  155. "email_notify": false,
  156. "is_parameterized": false,
  157. "database": "default"
  158. },
  159. "functions": [],
  160. "VERSION": "0.4.1",
  161. "file_resources": [],
  162. "settings": []
  163. }
  164. },
  165. {
  166. "name": "Airline Flight Data",
  167. "desc": "One time flights data analysis - ORC format",
  168. "dialects": ["hive"],
  169. "type": "0",
  170. "auto_load_only": true,
  171. "data": {
  172. "query": {
  173. "query": "-- Query 1\r\n\r\nWITH flightpath AS (\r\nSELECT\r\na.uniquecarrier auq,\r\na.flightnum afn,\r\nb.uniquecarrier buq,\r\nb.flightnum bfn,\r\nc.uniquecarrier cuq,\r\nc.flightnum cfn,\r\na.origin a_origin,\r\na.dest a_dest,\r\nb.dest b_dest,\r\nc.dest c_dest,\r\na.year,\r\na.month,\r\na.dayofmonth adom,\r\nb.dayofmonth bdom,\r\nc.dayofmonth cdom,\r\na.deptime adt,\r\na.arrtime aat,\r\nb.deptime bdt,\r\nb.arrtime bat,\r\nc.deptime cdt,\r\nc.arrtime cat,\r\na.tailnum a_tailnum,\r\nb.tailnum b_tailnum,\r\nc.tailnum c_tailnum,\r\nc.arrtime - a.deptime flighttime\r\nFROM\r\nflights A,\r\nflights B,\r\nflights C\r\nWHERE\r\n1 = 1\r\nAND b.year = a.year\r\nAND c.year = a.year\r\nAND b.month = a.month\r\nAND c.month = a.month\r\nAND a.dest = b.origin\r\nAND b.dest = c.origin\r\n)\r\nSELECT\r\nfp.*\r\nFROM\r\nflightpath fp\r\nWHERE\r\n1 = 1\r\nAND a_origin = 'JFK'\r\nAND (\r\na_dest = 'LAS'\r\nOR b_dest = 'LAS'\r\nOR c_dest = 'LAS'\r\n)\r\nAND year = 2000\r\nAND month = 1\r\nAND adom = bdom\r\nAND bdom = cdom\r\nAND floor(bdt / 100) - floor(aat / 100) > 1\r\nAND floor(bdt / 100) - floor(aat / 100) < 3\r\nORDER BY\r\nflighttime desc\r\n;\r\n\r\n\r\n-- Query 2\r\n\r\nSELECT flights.month month, avg(flights.depdelay) avgdelay\r\nFROM flights\r\nLEFT JOIN planes ON flights.tailnum = planes.tailnum\r\nWHERE planes.manufacturer LIKE 'AIRBUS%'\r\nAND flights.origin = 'JFK'\r\nGROUP BY flights.month\r\nORDER BY flights.month\r\n;\r\n\r\n\r\n-- Query 3\r\n\r\nSELECT airport,\r\norigin,\r\ncity,\r\ncountry,\r\nflightnum,\r\ndeptime,\r\ndepdelay\r\nFROM airports\r\nLEFT JOIN flights ON airports.iata=flights.origin\r\nWHERE flights.origin='SFO'\r\nAND month=8\r\nAND dayofmonth=6\r\nORDER BY deptime ASC\r\n;\r\n\r\n\r\n-- Query 4\r\n\r\nSELECT month,\r\ncount(*),\r\navg(depdelay),\r\nmax(depdelay),\r\navg(taxiout),\r\navg(cancelled),\r\navg(weatherdelay),\r\nmax(weatherdelay),\r\navg(nasdelay),\r\nmax(nasdelay),\r\navg(securitydelay),\r\nmax(securitydelay),\r\navg(lateaircraftdelay),\r\nmax(lateaircraftdelay),\r\navg(airtime),\r\navg(actualelapsedtime),\r\navg(distance)\r\nFROM flights\r\nGROUP BY month\r\nORDER BY month\r\n;\r\n\r\n\r\n-- Query 5\r\n-- Select airport with highest avg delay\r\n\r\nSELECT origin,\r\navg(depdelay+weatherdelay+lateaircraftdelay) AS total_delay_avg\r\nFROM flights\r\nWHERE depdelay IS NOT NULL and weatherdelay IS NOT NULL and lateaircraftdelay IS NOT NULL\r\nGROUP BY origin\r\nORDER BY total_delay_avg DESC\r\n;\r\n\r\n\r\n-- Query 6\r\n-- Select delays by month at that airport with highest avg delays\r\n\r\nSELECT month,\r\navg(depdelay+weatherdelay+lateaircraftdelay) AS total_delay_avg\r\nFROM flights\r\nWHERE origin='GCC'\r\nAND depdelay IS NOT NULL\r\nAND weatherdelay IS NOT NULL\r\nAND lateaircraftdelay IS NOT NULL\r\nGROUP BY month\r\nORDER BY total_delay_avg DESC\r\n;\r\n\r\n\r\n-- Query 7\r\n-- Get number of flights with delays that are too long\r\n\r\nSELECT count(flightnum)\r\nFROM flights\r\nWHERE depdelay >\r\n(SELECT 3*stddev(depdelay)\r\nFROM flights_s3)\r\nAND weatherdelay >\r\n(SELECT 3*stddev(weatherdelay)\r\nFROM flights_s3)\r\nAND lateaircraftdelay >\r\n(SELECT 3*stddev(lateaircraftdelay)\r\nFROM flights_s3)\r\n;\r\n\r\n\r\n-- Query 8\r\n-- Get number of flights with delays that are too long\r\n\r\nSELECT count(flightnum)\r\nFROM flights\r\nWHERE depdelay >\r\n(SELECT 3*stddev(depdelay)\r\nFROM flights)\r\nAND weatherdelay >\r\n(SELECT 3*stddev(weatherdelay)\r\nFROM flights)\r\nAND lateaircraftdelay >\r\n(SELECT 3*stddev(lateaircraftdelay)\r\nFROM flights)\r\n;\r\n\r\n\r\n-- Query 9\r\n-- Select several combinations of two delay type columns and total_delay to see which combinations of \r\n-- two delay factors are most likely to lead to the highest delay\r\n\r\nSELECT flightnum,\r\norigin,\r\n(depdelay+weatherdelay) AS dep_and_weather,\r\n(depdelay+lateaircraftdelay) AS dep_and_late_arrival,\r\n(weatherdelay+lateaircraftdelay) AS weather_and_late_arrival,\r\n(depdelay+weatherdelay+lateaircraftdelay) AS total_delay\r\nFROM flights\r\nWHERE depdelay IS NOT NULL\r\nAND weatherdelay IS NOT NULL\r\nAND lateaircraftdelay IS NOT NULL\r\n;\r\n",
  174. "type": 0,
  175. "email_notify": false,
  176. "is_parameterized": false,
  177. "database": "airline_ontime_orc"
  178. },
  179. "functions": [],
  180. "VERSION": "0.4.1",
  181. "file_resources": [],
  182. "settings": []
  183. }
  184. },
  185. {
  186. "name": "Airline Flight Data",
  187. "desc": "One time flights data analysis - Parquet format",
  188. "dialects": ["hive"],
  189. "type": "0",
  190. "auto_load_only": true,
  191. "data": {
  192. "query": {
  193. "query": "-- Query 1\r\n\r\nWITH flightpath AS (\r\nSELECT\r\na.uniquecarrier auq,\r\na.flightnum afn,\r\nb.uniquecarrier buq,\r\nb.flightnum bfn,\r\nc.uniquecarrier cuq,\r\nc.flightnum cfn,\r\na.origin a_origin,\r\na.dest a_dest,\r\nb.dest b_dest,\r\nc.dest c_dest,\r\na.year,\r\na.month,\r\na.dayofmonth adom,\r\nb.dayofmonth bdom,\r\nc.dayofmonth cdom,\r\na.deptime adt,\r\na.arrtime aat,\r\nb.deptime bdt,\r\nb.arrtime bat,\r\nc.deptime cdt,\r\nc.arrtime cat,\r\na.tailnum a_tailnum,\r\nb.tailnum b_tailnum,\r\nc.tailnum c_tailnum,\r\nc.arrtime - a.deptime flighttime\r\nFROM\r\nflights A,\r\nflights B,\r\nflights C\r\nWHERE\r\n1 = 1\r\nAND b.year = a.year\r\nAND c.year = a.year\r\nAND b.month = a.month\r\nAND c.month = a.month\r\nAND a.dest = b.origin\r\nAND b.dest = c.origin\r\n)\r\nSELECT\r\nfp.*\r\nFROM\r\nflightpath fp\r\nWHERE\r\n1 = 1\r\nAND a_origin = 'JFK'\r\nAND (\r\na_dest = 'LAS'\r\nOR b_dest = 'LAS'\r\nOR c_dest = 'LAS'\r\n)\r\nAND year = 2000\r\nAND month = 1\r\nAND adom = bdom\r\nAND bdom = cdom\r\nAND floor(bdt / 100) - floor(aat / 100) > 1\r\nAND floor(bdt / 100) - floor(aat / 100) < 3\r\nORDER BY\r\nflighttime desc\r\n;\r\n\r\n\r\n-- Query 2\r\n\r\nSELECT flights.month month, avg(flights.depdelay) avgdelay\r\nFROM flights\r\nLEFT JOIN planes ON flights.tailnum = planes.tailnum\r\nWHERE planes.manufacturer LIKE 'AIRBUS%'\r\nAND flights.origin = 'JFK'\r\nGROUP BY flights.month\r\nORDER BY flights.month\r\n;\r\n\r\n\r\n-- Query 3\r\n\r\nSELECT airport,\r\norigin,\r\ncity,\r\ncountry,\r\nflightnum,\r\ndeptime,\r\ndepdelay\r\nFROM airports\r\nLEFT JOIN flights ON airports.iata=flights.origin\r\nWHERE flights.origin='SFO'\r\nAND month=8\r\nAND dayofmonth=6\r\nORDER BY deptime ASC\r\n;\r\n\r\n\r\n-- Query 4\r\n\r\nSELECT month,\r\ncount(*),\r\navg(depdelay),\r\nmax(depdelay),\r\navg(taxiout),\r\navg(cancelled),\r\navg(weatherdelay),\r\nmax(weatherdelay),\r\navg(nasdelay),\r\nmax(nasdelay),\r\navg(securitydelay),\r\nmax(securitydelay),\r\navg(lateaircraftdelay),\r\nmax(lateaircraftdelay),\r\navg(airtime),\r\navg(actualelapsedtime),\r\navg(distance)\r\nFROM flights\r\nGROUP BY month\r\nORDER BY month\r\n;\r\n\r\n\r\n-- Query 5\r\n-- Select airport with highest avg delay\r\n\r\nSELECT origin,\r\navg(depdelay+weatherdelay+lateaircraftdelay) AS total_delay_avg\r\nFROM flights\r\nWHERE depdelay IS NOT NULL and weatherdelay IS NOT NULL and lateaircraftdelay IS NOT NULL\r\nGROUP BY origin\r\nORDER BY total_delay_avg DESC\r\n;\r\n\r\n\r\n-- Query 6\r\n-- Select delays by month at that airport with highest avg delays\r\n\r\nSELECT month,\r\navg(depdelay+weatherdelay+lateaircraftdelay) AS total_delay_avg\r\nFROM flights\r\nWHERE origin='GCC'\r\nAND depdelay IS NOT NULL\r\nAND weatherdelay IS NOT NULL\r\nAND lateaircraftdelay IS NOT NULL\r\nGROUP BY month\r\nORDER BY total_delay_avg DESC\r\n;\r\n\r\n\r\n-- Query 7\r\n-- Get number of flights with delays that are too long\r\n\r\nSELECT count(flightnum)\r\nFROM flights\r\nWHERE depdelay >\r\n(SELECT 3*stddev(depdelay)\r\nFROM flights_s3)\r\nAND weatherdelay >\r\n(SELECT 3*stddev(weatherdelay)\r\nFROM flights_s3)\r\nAND lateaircraftdelay >\r\n(SELECT 3*stddev(lateaircraftdelay)\r\nFROM flights_s3)\r\n;\r\n\r\n\r\n-- Query 8\r\n-- Get number of flights with delays that are too long\r\n\r\nSELECT count(flightnum)\r\nFROM flights\r\nWHERE depdelay >\r\n(SELECT 3*stddev(depdelay)\r\nFROM flights)\r\nAND weatherdelay >\r\n(SELECT 3*stddev(weatherdelay)\r\nFROM flights)\r\nAND lateaircraftdelay >\r\n(SELECT 3*stddev(lateaircraftdelay)\r\nFROM flights)\r\n;\r\n\r\n\r\n-- Query 9\r\n-- Select several combinations of two delay type columns and total_delay to see which combinations of \r\n-- two delay factors are most likely to lead to the highest delay\r\n\r\nSELECT flightnum,\r\norigin,\r\n(depdelay+weatherdelay) AS dep_and_weather,\r\n(depdelay+lateaircraftdelay) AS dep_and_late_arrival,\r\n(weatherdelay+lateaircraftdelay) AS weather_and_late_arrival,\r\n(depdelay+weatherdelay+lateaircraftdelay) AS total_delay\r\nFROM flights\r\nWHERE depdelay IS NOT NULL\r\nAND weatherdelay IS NOT NULL\r\nAND lateaircraftdelay IS NOT NULL\r\n;\r\n",
  194. "type": 0,
  195. "email_notify": false,
  196. "is_parameterized": false,
  197. "database": "airline_ontime_parquet"
  198. },
  199. "functions": [],
  200. "VERSION": "0.4.1",
  201. "file_resources": [],
  202. "settings": []
  203. }
  204. },
  205. {
  206. "name": "Airline Flight Data",
  207. "desc": "One time flights data analysis - Parquet format",
  208. "dialects": ["impala"],
  209. "type": "1",
  210. "auto_load_only": true,
  211. "data": {
  212. "query": {
  213. "query": "-- Query 1\r\n\r\nWITH flightpath AS (\r\nSELECT\r\na.uniquecarrier auq,\r\na.flightnum afn,\r\nb.uniquecarrier buq,\r\nb.flightnum bfn,\r\nc.uniquecarrier cuq,\r\nc.flightnum cfn,\r\na.origin a_origin,\r\na.dest a_dest,\r\nb.dest b_dest,\r\nc.dest c_dest,\r\na.year,\r\na.month,\r\na.dayofmonth adom,\r\nb.dayofmonth bdom,\r\nc.dayofmonth cdom,\r\na.deptime adt,\r\na.arrtime aat,\r\nb.deptime bdt,\r\nb.arrtime bat,\r\nc.deptime cdt,\r\nc.arrtime cat,\r\na.tailnum a_tailnum,\r\nb.tailnum b_tailnum,\r\nc.tailnum c_tailnum,\r\nc.arrtime - a.deptime flighttime\r\nFROM\r\nflights A,\r\nflights B,\r\nflights C\r\nWHERE\r\n1 = 1\r\nAND b.year = a.year\r\nAND c.year = a.year\r\nAND b.month = a.month\r\nAND c.month = a.month\r\nAND a.dest = b.origin\r\nAND b.dest = c.origin\r\n)\r\nSELECT\r\nfp.*\r\nFROM\r\nflightpath fp\r\nWHERE\r\n1 = 1\r\nAND a_origin = 'JFK'\r\nAND (\r\na_dest = 'LAS'\r\nOR b_dest = 'LAS'\r\nOR c_dest = 'LAS'\r\n)\r\nAND year = 2000\r\nAND month = 1\r\nAND adom = bdom\r\nAND bdom = cdom\r\nAND floor(bdt / 100) - floor(aat / 100) > 1\r\nAND floor(bdt / 100) - floor(aat / 100) < 3\r\nORDER BY\r\nflighttime desc\r\n;\r\n\r\n\r\n-- Query 2\r\n\r\nSELECT flights.month month, avg(flights.depdelay) avgdelay\r\nFROM flights\r\nLEFT JOIN planes ON flights.tailnum = planes.tailnum\r\nWHERE planes.manufacturer LIKE 'AIRBUS%'\r\nAND flights.origin = 'JFK'\r\nGROUP BY flights.month\r\nORDER BY flights.month\r\n;\r\n\r\n\r\n-- Query 3\r\n\r\nSELECT airport,\r\norigin,\r\ncity,\r\ncountry,\r\nflightnum,\r\ndeptime,\r\ndepdelay\r\nFROM airports\r\nLEFT JOIN flights ON airports.iata=flights.origin\r\nWHERE flights.origin='SFO'\r\nAND month=8\r\nAND dayofmonth=6\r\nORDER BY deptime ASC\r\n;\r\n\r\n\r\n-- Query 4\r\n\r\nSELECT month,\r\ncount(*),\r\navg(depdelay),\r\nmax(depdelay),\r\navg(taxiout),\r\navg(cancelled),\r\navg(weatherdelay),\r\nmax(weatherdelay),\r\navg(nasdelay),\r\nmax(nasdelay),\r\navg(securitydelay),\r\nmax(securitydelay),\r\navg(lateaircraftdelay),\r\nmax(lateaircraftdelay),\r\navg(airtime),\r\navg(actualelapsedtime),\r\navg(distance)\r\nFROM flights\r\nGROUP BY month\r\nORDER BY month\r\n;\r\n\r\n\r\n-- Query 5\r\n-- Select airport with highest avg delay\r\n\r\nSELECT origin,\r\navg(depdelay+weatherdelay+lateaircraftdelay) AS total_delay_avg\r\nFROM flights\r\nWHERE depdelay IS NOT NULL and weatherdelay IS NOT NULL and lateaircraftdelay IS NOT NULL\r\nGROUP BY origin\r\nORDER BY total_delay_avg DESC\r\n;\r\n\r\n\r\n-- Query 6\r\n-- Select delays by month at that airport with highest avg delays\r\n\r\nSELECT month,\r\navg(depdelay+weatherdelay+lateaircraftdelay) AS total_delay_avg\r\nFROM flights\r\nWHERE origin='GCC'\r\nAND depdelay IS NOT NULL\r\nAND weatherdelay IS NOT NULL\r\nAND lateaircraftdelay IS NOT NULL\r\nGROUP BY month\r\nORDER BY total_delay_avg DESC\r\n;\r\n\r\n\r\n-- Query 7\r\n-- Get number of flights with delays that are too long\r\n\r\nSELECT count(flightnum)\r\nFROM flights\r\nWHERE depdelay >\r\n(SELECT 3*stddev(depdelay)\r\nFROM flights_s3)\r\nAND weatherdelay >\r\n(SELECT 3*stddev(weatherdelay)\r\nFROM flights_s3)\r\nAND lateaircraftdelay >\r\n(SELECT 3*stddev(lateaircraftdelay)\r\nFROM flights_s3)\r\n;\r\n\r\n\r\n-- Query 8\r\n-- Get number of flights with delays that are too long\r\n\r\nSELECT count(flightnum)\r\nFROM flights\r\nWHERE depdelay >\r\n(SELECT 3*stddev(depdelay)\r\nFROM flights)\r\nAND weatherdelay >\r\n(SELECT 3*stddev(weatherdelay)\r\nFROM flights)\r\nAND lateaircraftdelay >\r\n(SELECT 3*stddev(lateaircraftdelay)\r\nFROM flights)\r\n;\r\n\r\n\r\n-- Query 9\r\n-- Select several combinations of two delay type columns and total_delay to see which combinations of \r\n-- two delay factors are most likely to lead to the highest delay\r\n\r\nSELECT flightnum,\r\norigin,\r\n(depdelay+weatherdelay) AS dep_and_weather,\r\n(depdelay+lateaircraftdelay) AS dep_and_late_arrival,\r\n(weatherdelay+lateaircraftdelay) AS weather_and_late_arrival,\r\n(depdelay+weatherdelay+lateaircraftdelay) AS total_delay\r\nFROM flights\r\nWHERE depdelay IS NOT NULL\r\nAND weatherdelay IS NOT NULL\r\nAND lateaircraftdelay IS NOT NULL\r\n;\r\n",
  214. "type": 0,
  215. "email_notify": false,
  216. "is_parameterized": false,
  217. "database": "airline_ontime_parquet"
  218. },
  219. "functions": [],
  220. "VERSION": "0.4.1",
  221. "file_resources": [],
  222. "settings": []
  223. }
  224. },
  225. {
  226. "name": "US City Population",
  227. "desc": "Small samples of number of inhabitants in some US cities",
  228. "dialects": ["phoenix"],
  229. "type": "2",
  230. "auto_load_only": false,
  231. "data": {
  232. "query": {
  233. "query": "\nSELECT\n state as \"State\",\n count(city) as \"City Count\",\n sum(population) as \"Population Sum\"\nFROM\n us_population\nGROUP BY\n state\nORDER BY\n sum(population) DESC\n;",
  234. "type": 0,
  235. "email_notify": false,
  236. "is_parameterized": false,
  237. "database": ""
  238. },
  239. "functions": [],
  240. "VERSION": "0.4.1",
  241. "file_resources": [],
  242. "settings": []
  243. }
  244. }
  245. ]