YouTube2Text

SQL for Data Analytics - Learn SQL in 4 Hours — Transcript

by Luke Barousse · 48,224 words · 6,515 segments · language en · Watch on YouTube

Full transcript

  1. 0:00data nerds welcome to this full course
  2. 0:01tutorial on how I use SQL for data
  3. 0:04analytics this is the course I wish I
  4. 0:06would have had when I first started
  5. 0:07learning this tool as it's a super easy
  6. 0:09to learn skill when taught properly and
  7. 0:11I feel like you can strongly master the
  8. 0:13basics by the end of this video now this
  9. 0:15tool is one of the most highly sought
  10. 0:16after skills in the data science
  11. 0:18Industry don't believe me let's check
  12. 0:19out the data for skills required in data
  13. 0:21analyst jobs SQL is the number one skill
  14. 0:25in almost half of job postings for data
  15. 0:27Engineers it's still number one and it's
  16. 0:29more than in half for data scientists
  17. 0:31it's the second most important skill
  18. 0:33right after python now SQL stands for
  19. 0:35structured query language and it can be
  20. 0:38spoken either SQL or SQL if I needed to
  21. 0:41perform analysis on my computer of a
  22. 0:43data set in a database sqls the
  23. 0:45programming language I'll be using to
  24. 0:47extract out any insights and this skill
  25. 0:49is something that I've been working on
  26. 0:50refining for years all the way from my
  27. 0:52first job as a data analyst in Corporate
  28. 0:54America to even my last role with Mr
  29. 0:57Beast squl is everywhere so what will'll
  30. 0:59be covering in this course well I've
  31. 1:01broken it up into three chapters we'll
  32. 1:03be starting at the very Basics and then
  33. 1:05building way up to an advanced section
  34. 1:08building our very own Capstone project
  35. 1:10for the basics chapter we're going to
  36. 1:11start at the very beginning including
  37. 1:13breaking down important Concepts behind
  38. 1:15SQL databases from there we're going to
  39. 1:17jump head first into actually practicing
  40. 1:19SQL queries focusing on the basics of
  41. 1:22common keywords simple analysis and even
  42. 1:24more advanced topics like joints now
  43. 1:27don't worry if you have no coding or
  44. 1:28analytical experience as this chapter is
  45. 1:31designed for you now after we get the
  46. 1:32basics down we're going to then jump
  47. 1:34into Advanced Techniques we're going to
  48. 1:36walk through creating and setting up
  49. 1:38your very own database locally on your
  50. 1:40own computer we're then going to move
  51. 1:42into more complex analysis using things
  52. 1:45like CTE and subqueries now you're
  53. 1:47easily going to forget these basic and
  54. 1:49advanced concepts unless you actually
  55. 1:51get into implementing what you learned
  56. 1:53and the best way to learn something is
  57. 1:54to build something and that's what we'll
  58. 1:56be doing in the Final Chapter we're
  59. 1:58going to be working to solve a real
  60. 1:59world problem problem analyzing the top
  61. 2:01skills and jobs in the data science
  62. 2:03Industry we'll be using the data set
  63. 2:05powering my app data nerd. Tech that
  64. 2:07provides insights on data science job
  65. 2:10postings and by the end of it you'll
  66. 2:11have your own custom project that you'll
  67. 2:14be able to showcase on GitHub for the
  68. 2:16world to see now I'm a firm believer in
  69. 2:18open sourcing education so this course
  70. 2:20is completely free and all the resources
  71. 2:24that you need for it are included so I'm
  72. 2:26going to be providing you locations to
  73. 2:28actually run your SQL queries along with
  74. 2:31the data sets when you build your
  75. 2:33project but I'll be honest YouTube isn't
  76. 2:35paying the bills like it used to so I
  77. 2:37have an option for those that want to
  78. 2:39actually support the course while also
  79. 2:41rewarding you for doing this for those
  80. 2:43using the link below to contribute I'm
  81. 2:45going to give you some extra perks that
  82. 2:47will help you learn SQL even faster
  83. 2:49you're going to have access to multiple
  84. 2:51practice problems within each section
  85. 2:53they break down the problems into easy
  86. 2:54medium and hard and even provide the
  87. 2:56solutions for completing the problems
  88. 2:58which will reinforce all the skills that
  89. 3:00we're learning in the video additionally
  90. 3:02I'm providing all the course notes for
  91. 3:04this video they're going to provide even
  92. 3:05more details and resources for the
  93. 3:07sections along with breaking down the
  94. 3:09queries in the videos a lot further and
  95. 3:12then once you've completed the course
  96. 3:14I'm going to award you a certificate of
  97. 3:15completion now one quick shout out
  98. 3:17before we jump into the first chapter on
  99. 3:19Basics explaining what is SQL I want to
  100. 3:21give a shout out to Kelly Adams She is
  101. 3:23the brains behind the majority of this
  102. 3:25content in this course she's a full-time
  103. 3:27data analyst that I've been following on
  104. 3:29LinkedIn for years now and I was beyond
  105. 3:31ecstatic whenever she said she'd team up
  106. 3:33with me to build this course I'll be
  107. 3:35linking Kelly's LinkedIn and also
  108. 3:37portfolio below the like button so be
  109. 3:39sure to check that out all right with
  110. 3:41that let's actually jump into the basics
  111. 3:43chapter all right welcome to this
  112. 3:45chapter on the basics and for this we're
  113. 3:47going to be focusing on the very
  114. 3:49fundamentals in this section and also
  115. 3:51the next so in this section we'll be
  116. 3:53breaking down what exactly is SQL and
  117. 3:56then after that I'm going to give you
  118. 3:57access to all the different data sets so
  119. 3:59you can work the problems right
  120. 4:01alongside me now what I'm showing here
  121. 4:03are the course notes and for those that
  122. 4:05have contributed to the course you'll
  123. 4:07have access to go right alongside me and
  124. 4:10see all the different notes as I'm
  125. 4:11walking you through this so with that
  126. 4:13let's actually dive into understanding
  127. 4:15what is SQL and for this we need to
  128. 4:18understand two major Concepts behind
  129. 4:20this the first concept is around where
  130. 4:22you'll be writing and executing your SQL
  131. 4:24queries and the other main concept is
  132. 4:26around databases where our data is
  133. 4:29actually stored so let's dive into this
  134. 4:31first a database is a collection of data
  135. 4:35and these things were made to hold
  136. 4:36massives amount of data an Excel file
  137. 4:39Can Only Hold around a million rows of
  138. 4:40data but a database can easily hold
  139. 4:43millions of Excel files so if you do the
  140. 4:46math that's a lot of rows of data now
  141. 4:47about those databases there's two major
  142. 4:49types of databases relational and
  143. 4:52non-relational relational databases
  144. 4:54include things like tables very
  145. 4:57structured data non-relational databases
  146. 4:59are for unstructured data we're going to
  147. 5:01dive into each in a little bit but first
  148. 5:03let's go back to where we're actually
  149. 5:05running and executing SQL now whenever
  150. 5:07we write out SQL code in order to
  151. 5:09request data from a database this is
  152. 5:12called a query and this SQL code can do
  153. 5:14a whole a heck lock more that just
  154. 5:16request data a common acronym associated
  155. 5:18with what it can do is called crud and
  156. 5:21it stands for create read update and
  157. 5:24delete with SQL keywords like create an
  158. 5:26insert into you can add new records then
  159. 5:29with keyword like select you can
  160. 5:31retrieve specific data you need next
  161. 5:33with the keyword update you can modify
  162. 5:35existing records and then finally one
  163. 5:37the scarest of alls if you need to
  164. 5:38remove records you can use delete now
  165. 5:40these are all commands we're going to be
  166. 5:41covering throughout the basic and
  167. 5:43advanced section so it's nothing you
  168. 5:44need to commit to memory right now so
  169. 5:46now we understand the basics of querying
  170. 5:48and also a database but where the heck
  171. 5:50are these databases even stored there's
  172. 5:52a couple major options you can either
  173. 5:54run it locally on your computer or you
  174. 5:57can use a server now for this course
  175. 6:00we're going to be running the database
  176. 6:01locally it's going to save a lot of
  177. 6:03costs and also I feel you learn a lot by
  178. 6:05running databases locally before you
  179. 6:07jump into something more complicated
  180. 6:09like a server local computers are also
  181. 6:11used during development and testing so
  182. 6:14you may find yourself from time to time
  183. 6:15actually downloading a database on your
  184. 6:17computer so you don't mess with the real
  185. 6:19one so where a real world databas is
  186. 6:21typically located and you have two major
  187. 6:23options one is a company server and
  188. 6:25that's something that's actually hosted
  189. 6:27internally and you have that the company
  190. 6:30full control of This Server this option
  191. 6:32is nicknamed on Prem now the other
  192. 6:35options like Cloud providers do this for
  193. 6:37you companies like AWS Google cloud and
  194. 6:39aure are known for this and frankly for
  195. 6:42a price they'll manage all the different
  196. 6:44headaches of managing your own server so
  197. 6:47this is conveniently called serverless
  198. 6:49and that doesn't mean there are no
  199. 6:50servers it just means you don't have to
  200. 6:52have the headaches so now that we
  201. 6:53understand the databases can be stored
  202. 6:55either on your computer or on a server
  203. 6:57what are the different databases we can
  204. 6:59store in these locations well there are
  205. 7:01two major types relational and
  206. 7:04non-relational databases relational
  207. 7:06databases store data in rows and columns
  208. 7:10this is very much used in transactional
  209. 7:13applications say I had a database of job
  210. 7:15postings that companies go to daily in
  211. 7:18order to transact with an update of what
  212. 7:21jobs are available you could have one
  213. 7:23table to keep track of all the different
  214. 7:25jobs and then you could have an
  215. 7:27Associated table to keep track of all
  216. 7:29the different different companies and
  217. 7:30their information there would then be
  218. 7:32things like IDs within the two in order
  219. 7:35for you to relate the different tables
  220. 7:37hence relational databases this course
  221. 7:39will be primarily focusing on using SQL
  222. 7:42to interact with relational databases
  223. 7:45but the other type of databases are
  224. 7:46non-relational databases commonly known
  225. 7:49as nosql but nosql doesn't stand for not
  226. 7:53SQL it stands for not only SQL these
  227. 7:56type of databases support a host of
  228. 7:58different options including unstructured
  229. 8:01data so not only can it include more
  230. 8:03structured data like column and row
  231. 8:05based data but also you can have other
  232. 8:07types like key value payers graph-based
  233. 8:10and even document based these are using
  234. 8:13your everyday applications to track your
  235. 8:15connections on LinkedIn or to manage
  236. 8:17your docs in Google doc so what are some
  237. 8:19popular database options well if we
  238. 8:22navigate to the stack Overflow developer
  239. 8:24survey from 2023 over 76,000 respondents
  240. 8:28voted on what is their database of
  241. 8:30choice if we look at the top five
  242. 8:32options four of these are relational
  243. 8:35databases and only one is a
  244. 8:37non-relational database and for this
  245. 8:39we're going to be focusing on the number
  246. 8:40one and three option the first one is
  247. 8:42pronounced postgress you don't have to
  248. 8:44pronounce the SQL at the end the other
  249. 8:46one per of the Creator is called SQ
  250. 8:48light but I'm pretty lazy so I'm just
  251. 8:50going to call it SQL light so we covered
  252. 8:52everything we needed to know for
  253. 8:54databases but where the heck are we
  254. 8:56going to be actually writing and running
  255. 8:58these queries well there's a few few
  256. 8:59popular options for this and it's
  257. 9:01commonly done in an editor whether
  258. 9:03that's from a database provider a cloud
  259. 9:05provider or even just a plain old code
  260. 9:08editor let's talk about database
  261. 9:09provided editors first for popular
  262. 9:12options like postgress and MySQL they'll
  263. 9:14actually provide you an application to
  264. 9:17use on your computer to access their
  265. 9:19databases inside of you'll be able to
  266. 9:21track status of your different tables
  267. 9:23and actually look at the progress of it
  268. 9:25and you can even do something as simple
  269. 9:26as writing SQL queries now if you're
  270. 9:28using something like a cloud provider
  271. 9:30like Google cloud or Azure they're also
  272. 9:33going to give you the option inside of a
  273. 9:34web browser in order to interact with
  274. 9:37your database I keep a lot of my data on
  275. 9:39Google cloud and it allows you to
  276. 9:41monitor all the different tables that
  277. 9:43you have along with an interface to go
  278. 9:45in and query the data now the third
  279. 9:47option is the one that we're actually
  280. 9:48going to be using but I want you to be
  281. 9:49aware of the other two and this is a
  282. 9:51code editor during the second and third
  283. 9:53chapters of this course we're going to
  284. 9:55be focusing on using a popular option
  285. 9:57VSS code which allows you to not only
  286. 10:00manage all your different SQL files that
  287. 10:02we'll be using for this but it will also
  288. 10:04allow us to run these queries for the
  289. 10:06beginner section we're going to be using
  290. 10:08a code editor right inside of your
  291. 10:10browser this bad boy is called sqlite
  292. 10:13viz and it's completely free to use this
  293. 10:15is a popular open- Source option that
  294. 10:17allows you to run queries right inside
  295. 10:20your browser and in the next video we're
  296. 10:22going to talk about more about what the
  297. 10:23data and databases we're using inside of
  298. 10:26things like sqlite viz and vs code all
  299. 10:29right so now you should have a basic
  300. 10:31understanding of how and where SQL
  301. 10:33queries are run and then what and how
  302. 10:36databases are used in order to store
  303. 10:39data so with that let's actually dive
  304. 10:40into seeing where you're going to be
  305. 10:42playing with all this data all right see
  306. 10:44you in the next one all right welcome to
  307. 10:46the section on an intro to a course
  308. 10:48where we're going to be focusing on
  309. 10:50understanding what data sets we're going
  310. 10:51to be using for this and how we're going
  311. 10:53to be running those data sets but before
  312. 10:55we even talk about any of these data
  313. 10:56sets we need to understand what problem
  314. 10:58we're going to be solving for the
  315. 11:00entirety of this course you're going to
  316. 11:02be taking the perspective of a job
  317. 11:04Seeker with the goal of identifying what
  318. 11:06are some of the highest paying jobs
  319. 11:08along with what are the most optimal
  320. 11:10skills to learn so in order to solve
  321. 11:12this problem you need a data set that
  322. 11:14has this type of data in it well luckily
  323. 11:16I've been collecting this type of data
  324. 11:19in my app data nerd. te and inside of
  325. 11:22this app it Aggregates job postings in
  326. 11:25the data science Industry in order for
  327. 11:27you to see things like what are the top
  328. 11:30skills for data analyst additionally it
  329. 11:32also includes pay requirement for the
  330. 11:34different jobs along with detailing how
  331. 11:37these skills are paid based on a certain
  332. 11:40job title so the data set that we're
  333. 11:42using for this course is from that app
  334. 11:44and specifically it's for data science
  335. 11:46job postings in 2023 here is an ER or
  336. 11:50entity relationship diagram about the
  337. 11:52different tables in this data set we
  338. 11:55have four major tables one fact table
  339. 11:58con containing all our different job
  340. 12:00postings then two Dimension tables that
  341. 12:03contain key information about the skills
  342. 12:05required for those jobs and then finally
  343. 12:08a dimension table around the different
  344. 12:09companies that are posting these jobs so
  345. 12:12what the heck are these fact Dimension
  346. 12:13tables you probably never heard of fact
  347. 12:15tables contain the core data for the
  348. 12:18analysis they measure and record actual
  349. 12:20events so in our case the different job
  350. 12:22postings because of this there's
  351. 12:25typically a high volume of records and
  352. 12:26then there's usually some sort of
  353. 12:28foreign key to associate it to a
  354. 12:30dimension table the dimension tables
  355. 12:33describe attributes or dimensions of the
  356. 12:35data so in our case skills or company
  357. 12:37data these are really important in
  358. 12:39supporting filtering and grouping
  359. 12:42different sets of data they usually have
  360. 12:44fewer rows of data but generally are
  361. 12:46more descriptive anyway going back to
  362. 12:47the ERD the job postings fact table has
  363. 12:50a job ID column in it and this is a
  364. 12:53unique ID to all the different job
  365. 12:55postings this ID is inside the skills
  366. 12:58job deal table as a foreign key and we
  367. 13:01have this in a separate table because
  368. 13:03there can be multiple skill IDs
  369. 13:05associated with the job ID and
  370. 13:07conversely this is associated to the
  371. 13:09skills dim table which actually has the
  372. 13:11list and the type of skills that are
  373. 13:14associated to the job back to that job
  374. 13:16postings fact table we also have a
  375. 13:18company ID column and this column is
  376. 13:21associated to the company dim table
  377. 13:24which in this table has key information
  378. 13:26about the companies such as its name and
  379. 13:29its URL that you can access anyway
  380. 13:31that's all theoretical talk let's
  381. 13:33actually dive into actually looking at
  382. 13:35the different data we're going to be
  383. 13:36using for this and for this you can
  384. 13:38navigate to this URL right here and it's
  385. 13:41could provide access via that tool SQL
  386. 13:44light viz in order to analyze and
  387. 13:46visualize our SQL queries we're going to
  388. 13:48dive more into this tool in the next
  389. 13:50section but for now understand that I'm
  390. 13:52running a query up at the top and the
  391. 13:54results are appearing below anyway this
  392. 13:57is the job postings f back table so for
  393. 14:00this analysis that we're going to be
  394. 14:01doing I'm going to be analyzing it from
  395. 14:03the perspective of a data analyst
  396. 14:05because I'm a data analyst and that's
  397. 14:07what I'm interested in but you actually
  398. 14:10have different job titles available to
  399. 14:12use here's a list of all the different
  400. 14:14options you can not only look at data
  401. 14:16analysts but also data scientists or
  402. 14:17data Engineers if you wanted to you can
  403. 14:19explore senior roles or even roles that
  404. 14:22are slightly related such as business
  405. 14:23analyst machine learning engineer
  406. 14:25software engineer and Cloud engineer so
  407. 14:27feel free during this course to modify
  408. 14:29any of my queries in order to adapt it
  409. 14:32to what job you care more about now the
  410. 14:34data set includes postings from around
  411. 14:36the world I'm primarily going to be
  412. 14:38searching it for remote jobs but you can
  413. 14:41adapt it to any location that you find
  414. 14:43fit and the last thing to app about is
  415. 14:45it also includes a lot of companies from
  416. 14:47diverse perspectives not only tech
  417. 14:49companies but also Commerce companies
  418. 14:51now there is one other data set used in
  419. 14:53this course and we're only going to use
  420. 14:54it from time to time specifically we
  421. 14:56need it for our arithmetic operations
  422. 14:58this this is a fictitious data set Based
  423. 15:01on data science job invoices there's
  424. 15:04only one table inside of it and it's
  425. 15:05conveniently named invoices fact we'll
  426. 15:08go over more of this data set in a
  427. 15:09future section so we covered what data
  428. 15:12we're going to be using for this but
  429. 15:14what database are we going to be using
  430. 15:16to actually host all this data well as
  431. 15:18mentioned in the last video we're going
  432. 15:20to be focusing on postgress and SQL
  433. 15:23light this beginner chapter will all be
  434. 15:26based on SQL light it's a lightweight
  435. 15:29file-based database and it's ideal for
  436. 15:31small to medium apps with zero
  437. 15:33configuration it's so small in fact that
  438. 15:35it's actually running right inside your
  439. 15:37browser whenever you access this tool
  440. 15:39SQL like Vis for the second and third
  441. 15:42chapters in this we'll be using
  442. 15:44postgress it's an advanced open-source
  443. 15:47relational database suited for large
  444. 15:49applications and it supports a lot more
  445. 15:51complex queries so because it's open
  446. 15:53source you'll be able to download this
  447. 15:55database on your computer for free and
  448. 15:57use it now I do want to call out there
  449. 15:59are some slight syntax differences
  450. 16:02between the two and syntax is the set of
  451. 16:04rules and structures you have to follow
  452. 16:06while programming for the majority of
  453. 16:08course commands like this are going to
  454. 16:10work in both these different databases
  455. 16:12it will only come to very Nuance
  456. 16:13situations where these two databases are
  457. 16:16going to have differences in it but
  458. 16:17really we're not going to find a lot now
  459. 16:19that we laid all this ground work let's
  460. 16:20actually jump into doing all these
  461. 16:22different queries for those that
  462. 16:23purchase the course notes whenever you
  463. 16:25navigate to a section it's not going to
  464. 16:27only showcase what databases you're
  465. 16:29using for this but also we'll have an
  466. 16:31overview of what we're covering for each
  467. 16:33of the Min sections within the chapter
  468. 16:34you'll have some basic notes on the
  469. 16:36topic along with the query and the
  470. 16:38expected results when we get to the
  471. 16:40practice problems within the chapter it
  472. 16:42will have similarly not only the data
  473. 16:44set but then also the questions and the
  474. 16:47solution all right so with that enough
  475. 16:49me yapping let's dive into it see you in
  476. 16:51the next one all right welcome to this
  477. 16:53basic section where we have this mini
  478. 16:55section on the basics we're going to
  479. 16:58focus on a handful of keywords that I
  480. 17:00use on a routine basis and I think you
  481. 17:03need to have committed to memory in
  482. 17:04order to know how to use and so we'll be
  483. 17:06actually implementing it and running
  484. 17:08queries with these commands to learn
  485. 17:09more about them first up it's actually
  486. 17:12instead of one keyword we're going to
  487. 17:13focus on three and this is going to be
  488. 17:15saying select star from and a database
  489. 17:19table select is a keyword that
  490. 17:21identifies a column or columns we want
  491. 17:23to connect to and from identifies the
  492. 17:25table or tables we want to connect to
  493. 17:28let me show you what I mean so routinely
  494. 17:29I'll need access to some sort of
  495. 17:31database for my job I'll have to reach
  496. 17:33out to something like a database
  497. 17:34administrator and they'll give me access
  498. 17:36anyway select and from is how I'm going
  499. 17:38to verify that I have access to the
  500. 17:40database so in this case let's say I got
  501. 17:42this email and it says I have now access
  502. 17:44to this job 2023 and it has all these
  503. 17:47tables in it I want to go now verify
  504. 17:48that I have access to it so let's verify
  505. 17:50we have access to this and you're going
  506. 17:52to navigate over to the URL that I have
  507. 17:55linked right here and this is going to
  508. 17:58be our little workspace that we're be
  509. 17:59working in in order to verify access now
  510. 18:02when you pop this open you should have
  511. 18:04two separate Windows one an upper window
  512. 18:07where you're going to write the query
  513. 18:08and then a lower window below this that
  514. 18:10is going to display all the different
  515. 18:12results that you have we can see here
  516. 18:14that this query is already executed I
  517. 18:17can open up this left side pane right
  518. 18:19here and actually look into the database
  519. 18:22that we have access to in this which is
  520. 18:23jobs
  521. 18:252023 then all of the tables within that
  522. 18:28database so these four tables and then
  523. 18:30you can further break it down or see
  524. 18:32what's in it by expanding this and then
  525. 18:35this displays the columns within that
  526. 18:38table so I'm going to go ahead and close
  527. 18:40that out cuz I don't want to really look
  528. 18:42at it and that first statement should
  529. 18:44already appear on your window right here
  530. 18:47you can go ahead and run it again if you
  531. 18:50want by either pressing run SQL query
  532. 18:53and it'll go through and fetch results
  533. 18:55looks like there's 33,500 available you
  534. 18:58can also as a quick shortcut press
  535. 19:01controll enter and it will also run the
  536. 19:04query now anytime I get access to the
  537. 19:06database this is one of the first
  538. 19:07commands that I'm running in order to
  539. 19:10see all the different columns that I
  540. 19:12have access to and to ensure actually
  541. 19:14that I have access to that table so in
  542. 19:17this case job posting is fact if I
  543. 19:19wanted to I could also see another table
  544. 19:22in this data set I can put in company
  545. 19:24dim and press control enter and see that
  546. 19:27hey yeah I also have access to this one
  547. 19:29now these commands must be written in
  548. 19:32this order you would think you would
  549. 19:34want to say from a table select these
  550. 19:39columns um because that would be the
  551. 19:41order but if you tried to actually run
  552. 19:43this control enter it's going to give
  553. 19:45you this error syntax it has to be in
  554. 19:47that specific order of Select and from
  555. 19:51and I'm going to be sprinkling also best
  556. 19:52practices in through this so you'll
  557. 19:54notice the select and from in this case
  558. 19:57are all capital letters these keywords
  559. 19:59are not case are not case sensitive so
  560. 20:04in this case I could have lowercase and
  561. 20:06also uppercase mixed in with each other
  562. 20:08they're still going to work the values
  563. 20:10for things like the table name are case
  564. 20:14sensitive depending on the database
  565. 20:16we're using SQL light in this case so if
  566. 20:19I were to use a Capital C it's still
  567. 20:21going to work but whenever we start
  568. 20:23using postgress in the basic or in the
  569. 20:25advaned section it is going to be case
  570. 20:27sensitive so it's best practice to just
  571. 20:30leave this lowercase as it was intended
  572. 20:33in general these uppercase keywords and
  573. 20:36then lowercase of things like the column
  574. 20:38names or table names makes it easier to
  575. 20:42read and so that's what you want to do
  576. 20:44especially whenever you have to get into
  577. 20:45troubleshooting later you want to be
  578. 20:46able to easily read it and able to edit
  579. 20:48it now in this example we selected all
  580. 20:52columns but there's going to be cases
  581. 20:53where you don't want to select all
  582. 20:54columns not argue in most cases you
  583. 20:56don't want to select all columns it's
  584. 20:58very resource intensive for the server
  585. 21:01that's hosting this database to provide
  586. 21:03all those columns so you'd want to
  587. 21:06actually fine-tune the specific columns
  588. 21:09you want to use so in this case let's
  589. 21:11say I wanted only the two columns of job
  590. 21:14title short and job location instead of
  591. 21:17using this asterisk which is used to
  592. 21:21select all the columns instead I would
  593. 21:24just specify the columns so I'd say job
  594. 21:27title short
  595. 21:29and also job location I'm going to put a
  596. 21:31comma between each one of those to say
  597. 21:34that hey we're moving on to the next one
  598. 21:36this case when I press control enter
  599. 21:38executing the query we can see we have
  600. 21:40now these two columns shown now moving
  601. 21:42in some best practice for this one I
  602. 21:45like to have it to where whenever I'm
  603. 21:47selecting multiple columns I put it on
  604. 21:50separate lines to make it just more
  605. 21:52readable now with specifying these
  606. 21:54column names from a table they can
  607. 21:57actually be specified
  608. 21:59by saying the table name itself and then
  609. 22:01using this dot operator to then showcase
  610. 22:05the column after it I can do this
  611. 22:08actually for both of the v's here
  612. 22:10because they're both within that same
  613. 22:12table and whenever I run this query
  614. 22:15going to get the same results now this
  615. 22:17is going to be more important later on
  616. 22:19whenever we're combining multiple tables
  617. 22:22and you actually need to specify where
  618. 22:24this column is coming from within a
  619. 22:26table but in this case because we're
  620. 22:28only using one table I'm going to say
  621. 22:31it's not necessary and I'm going to go
  622. 22:34ahead and remove it but I just want you
  623. 22:35to be aware of it for the time being and
  624. 22:37show you that it still works all right
  625. 22:39so we already understand that quering
  626. 22:42all the different Columns of data set
  627. 22:43can be intensive for a Ser ex actually
  628. 22:46for really big data sets another thing
  629. 22:48that we want to do besides limiting The
  630. 22:50Columns is actually limiting the amount
  631. 22:53of rows and this can be done via the
  632. 22:55limit statement we can specify any
  633. 22:59number of values after this and this
  634. 23:02will specify the number of rows we want
  635. 23:04it to return right now these results are
  636. 23:06returning around
  637. 23:0833,000 job postings back so in this case
  638. 23:11let's say I only want to provide back
  639. 23:14five I'd put limit five and that limit
  640. 23:17five needs to come after the select and
  641. 23:20from statements and it's the very last
  642. 23:22statement you'll ever be writing inside
  643. 23:24of a SQL statement I'll press contrl
  644. 23:27enter and now we have five rows
  645. 23:29retrieved we can also see that for the
  646. 23:31five rows retrieved it only took 026
  647. 23:35seconds running this without that limit
  648. 23:38we can see that it takes around three
  649. 23:40times longer to get all those different
  650. 23:43rows now we're working with a relatively
  651. 23:45small data set so you're like look this
  652. 23:47is only milliseconds yes whenever we
  653. 23:50start getting into millions or even
  654. 23:51billions of rows this is going to add up
  655. 23:54and limit is going to save you some time
  656. 23:56one note on best practices so I talked
  657. 23:59about indenting these lines to make it
  658. 24:03more readable typical best practice is
  659. 24:05to have anywhere between two and four
  660. 24:08spaces personally for me I just hit Tab
  661. 24:11and it automatically inserts four spaces
  662. 24:13into here I could also do multiple
  663. 24:16different tabs and if I were to press
  664. 24:18controll enter in this case it's still
  665. 24:21going to execute whenever your SQL
  666. 24:23statement is sent over to the database
  667. 24:25itself so effectively all that
  668. 24:27indentation is removed and in this case
  669. 24:29like it's one line although this is hard
  670. 24:30for a human to read the database itself
  671. 24:33can obviously go through it and
  672. 24:34understand what it needs to be next up
  673. 24:36is the distinct keyword and this one is
  674. 24:38going to follow select in order to
  675. 24:41select a distinct amount of values
  676. 24:44within the rows of a column this is
  677. 24:47going to be a very resource intense type
  678. 24:49of calculation because it has to go
  679. 24:51through all the values in a colum column
  680. 24:54and then Aggregate and find what are the
  681. 24:56distinct values so let's take for
  682. 24:59example this job title short column
  683. 25:01right here I'm going to go ahead and
  684. 25:04reset this to include all the different
  685. 25:06values if I scroll down it I can see a
  686. 25:09lot of the values in here such as data
  687. 25:11scientist are repetitive and then data
  688. 25:13engineer I've seen multiple times that
  689. 25:15analyst so let's say I want to get all
  690. 25:18the unique values from this in this case
  691. 25:21I'll remove that other column and then
  692. 25:23specify distinct and from here press
  693. 25:27control enter to run it now I also
  694. 25:29didn't have that limit command remember
  695. 25:31so now we have 10 rows retrieved and
  696. 25:34these are all the different values or
  697. 25:36unique values from this job title short
  698. 25:40column now this isn't only limited to
  699. 25:43categorical data like in this case let's
  700. 25:46say I wanted to get the unique values
  701. 25:48from the average salary column now I
  702. 25:51could do the same thing of Select
  703. 25:53distinct salary year average column from
  704. 25:56this database pressing control enter and
  705. 25:59then from here I now have all those
  706. 26:02different unique values within it looks
  707. 26:04like there's over 2700 unique values now
  708. 26:07you may notice I have two queries within
  709. 26:09here and you can see that each one of
  710. 26:12these queries I've added a semicolon at
  711. 26:14the end the semicolon sometimes you'll
  712. 26:16see me use it sometimes you won't it's
  713. 26:18used to symbolize that this is the end
  714. 26:21of the sequel statement that you want to
  715. 26:23execute this case we have two separate
  716. 26:25and distinct uh SQL statements uh no pun
  717. 26:28intended with that and in this case with
  718. 26:32our editor we can only show one result
  719. 26:36of a SQL statement mainly that last one
  720. 26:39in this window right here when we get to
  721. 26:41the Advance section and we start using a
  722. 26:43different code editor you'll see how you
  723. 26:45can actually run all these different
  724. 26:47queries and have them populate in
  725. 26:49different tabs anyway for the time being
  726. 26:51anytime you're running queries I like to
  727. 26:53just keep it one in there and whether
  728. 26:55you have a semicolon or not it's up to
  729. 26:57you I'm going to leave it semicolon free
  730. 27:00next is the wear statement and this is
  731. 27:02used in cases when we want to filter out
  732. 27:05particular data we already talked about
  733. 27:07specifically now you can do things like
  734. 27:09select columns or limit the amount now
  735. 27:12we can go down even further and actually
  736. 27:14filter into what we need all right going
  737. 27:16back to a query where we have the four
  738. 27:18Columns of interest that we're looking
  739. 27:20at from our job postings fact table and
  740. 27:23we can see we have a lot of different
  741. 27:25values from different job titles short
  742. 27:28so we can use the wear statement to
  743. 27:31filter down to something more I'm more
  744. 27:33interested in such as data analyst the
  745. 27:36wear statement will be always directly
  746. 27:39after the from statement and we want to
  747. 27:42specify a condition we want to specify
  748. 27:45that that the job title short is equal
  749. 27:48to data analyst now we can go into
  750. 27:50either other condition such as greater
  751. 27:52than less than all that we're going to
  752. 27:54keep it really simple for now now the
  753. 27:56main thing to note right is that data
  754. 27:58analyst is in quotes in this case
  755. 28:01because it's a string character and it's
  756. 28:04immediately following that column
  757. 28:06whether there's spaces in here or not
  758. 28:08that doesn't really matter I just do
  759. 28:09this for readability pressing control
  760. 28:11enter we can see that we've now filtered
  761. 28:14in on this data and it only has data
  762. 28:18analysts so previously we had around
  763. 28:1930,000 rows now we have less than 10,000
  764. 28:23rows and we're not just limited to
  765. 28:25categorical or that text data we could
  766. 28:28also do it for numerical data so in the
  767. 28:30case of that salary yearly average
  768. 28:33column we could say hey we want to have
  769. 28:35everything that's greater than
  770. 28:37$90,000 and then now on scrolling
  771. 28:40through it we're can see that we do we
  772. 28:41have around 16,000 values that meet this
  773. 28:43condition now now that we're adding all
  774. 28:45of these more complex conditions this
  775. 28:49adds a great use case of now adding
  776. 28:52comments comments are denoted by these
  777. 28:55two dashes or tax if you're from the
  778. 28:58military before something that follows
  779. 29:01it so anything to the right of these two
  780. 29:05dashes is ignored no matter where those
  781. 29:07two dashes are placed and this is the
  782. 29:11standard practice of documenting your
  783. 29:13code and if you do something complex
  784. 29:16keeping track of it typically a comment
  785. 29:17would come at the beginning of a query
  786. 29:19to specify what's going on in here and
  787. 29:22in this case it's right at the front
  788. 29:24executing this query you can see that it
  789. 29:26ignored it you can even put put it after
  790. 29:28a SQL command as you can see here it's
  791. 29:31grayed out so that means that basically
  792. 29:33showing to you that it's going to be
  793. 29:34ignored and so in this case when
  794. 29:36pressing control enter still executed
  795. 29:38and now I have a documentation for why I
  796. 29:41maybe filtered out this certain subset
  797. 29:43of data the other common use case of
  798. 29:45this is if you're debugging or
  799. 29:46troubleshooting say I didn't want to
  800. 29:48care about this column or this column
  801. 29:51right here I can then put those two
  802. 29:53dashes in front of it whenever I run the
  803. 29:55query it only Returns the columns I
  804. 29:57don't have have the dashes in front of
  805. 29:58it now the other comment besides a
  806. 30:00single line comment it's a multi-line
  807. 30:02comment and it's denoted by a forward SL
  808. 30:06Asis and then an asteris forward slash
  809. 30:09that forward or backs slash just forward
  810. 30:11slash we're good anyway this is a
  811. 30:12multi-line comment and it's commonly
  812. 30:14used whenever you have to use well
  813. 30:15multiple lines but when you have to be
  814. 30:17more robust in your description on what
  815. 30:19you're trying to convey let's say I
  816. 30:21wanted to convey to whoever's going to
  817. 30:23be using this query why do I keep on
  818. 30:25using these four Columns of Interest
  819. 30:27over and over again well I can leave a
  820. 30:29note section in here that says hey these
  821. 30:31are going to be the most common you're
  822. 30:32going to see throughout these queries
  823. 30:35and here's the reason why well they
  824. 30:37provide the most comprehensive view of
  825. 30:38the data and there's the common factors
  826. 30:40that most people are looking at um we
  827. 30:43also don't want to call all the columns
  828. 30:44because it will just take up too much
  829. 30:45processing anyway if we go and run this
  830. 30:49query we can see that hey it is in fact
  831. 30:52shown and just to show the point if I
  832. 30:56were to remove these op ators right here
  833. 30:58and try to actually try to run this
  834. 31:01query it would give me an error near the
  835. 31:03note because it's going to try to
  836. 31:04execute this and things it's SQL syntax
  837. 31:07so I just fix that up real quick all
  838. 31:09right and the last keyword that we're
  839. 31:10going to cover before we get into some
  840. 31:11practice is order by as you guessed it
  841. 31:15this is used to specify a column and
  842. 31:19order it by that value so let's go ahead
  843. 31:22and use this order buy is going to come
  844. 31:24almost directly last the only thing that
  845. 31:26would come after order buy is a limit
  846. 31:29keyword in this case let's say we want
  847. 31:31to actually Aggregate and be able to see
  848. 31:35the salary from lowest to high pressing
  849. 31:39control enter it's going to go ahead and
  850. 31:41execute now it's going to notice here
  851. 31:43that we have null values first and
  852. 31:46that's because null means that there is
  853. 31:49nothing there for that value so it's
  854. 31:52even less than if you will Zero but if
  855. 31:54we scrolled over some pages that I've
  856. 31:56done here we can see that now yes when
  857. 32:00we have values inside of here it is
  858. 32:03going from that low to high those values
  859. 32:06are slowly rising and in an ordered case
  860. 32:09now this is lowest to highest which
  861. 32:11actually you if you were write ASC and
  862. 32:15go ahead and execute this it's doing the
  863. 32:17same thing here it's doing it in
  864. 32:19ascending order but now we don't need to
  865. 32:22necessarily write uh ASC um especially
  866. 32:25as it's sort of repetitive but if you do
  867. 32:28want it in descending order from highest
  868. 32:30to lowest you would then specify
  869. 32:33DEC and executing this query we're now
  870. 32:37getting it from the highest to lowest
  871. 32:39this would be really good in this case
  872. 32:40we want to see what is the highest
  873. 32:42salary we can now see it 650,000 now you
  874. 32:45may be curious what order should you be
  875. 32:48writing these commands in well here's a
  876. 32:51little convenient little cheat sheet on
  877. 32:53what you should be following for this
  878. 32:55follow it goes select from where Group
  879. 32:57by
  880. 32:58having order bu and limit now I don't
  881. 33:01have these commands memorized I even
  882. 33:03asked chat gbt for pneumonic on how to
  883. 33:06memorize this and it said super fast
  884. 33:08works great beneath the surface and has
  885. 33:10outstanding balance and Leadership and I
  886. 33:13going to use that mainly we're going to
  887. 33:15go with trial and error that's how I've
  888. 33:17memorized this over the years you're
  889. 33:18going to make mistakes get out of order
  890. 33:20but you'll understand what the error
  891. 33:22message is and you'll adjust from there
  892. 33:23all right now that we cover all of those
  893. 33:25Basics keywords now it's your time to go
  894. 33:28in and actually practice this I would
  895. 33:30play around with all those different
  896. 33:31keywords that we have also exploring all
  897. 33:34those different tables that you have
  898. 33:36available right now now for those that
  899. 33:39purchase the course notes and
  900. 33:40certificates you have some specific
  901. 33:43practice problems available to you um
  902. 33:45there's about five for this section
  903. 33:47right now we'll be adding to this um and
  904. 33:50in it you'll have things like the
  905. 33:51solution and also results to make sure
  906. 33:54that you're on track and actually
  907. 33:55following along and doing it correctly
  908. 33:57all right good luck with these see you
  909. 33:59in the next
  910. 34:02one all right let's get into this
  911. 34:04section now on comparison and also
  912. 34:06logical operators and you've been
  913. 34:08exposed to this previously when we use
  914. 34:11that wear keyword before to filter for
  915. 34:15job titles of data analyst we used an
  916. 34:18equal operator this is called a
  917. 34:19comparison operator we're going to go
  918. 34:21over all the different types for this
  919. 34:23these type of operators are used after
  920. 34:25the wear or even the having Glock clause
  921. 34:28in this section we're going to be
  922. 34:29focusing on the wear Clause we'll move
  923. 34:31on to the having as we get more advanced
  924. 34:34now in addition to this also we'll be
  925. 34:36using the logical operators which allows
  926. 34:39even more advanced functionality to
  927. 34:42fine-tune how you want to filter data
  928. 34:45since we already understand the
  929. 34:46fundamentals of the equal operator we're
  930. 34:48going to move on to the not equal
  931. 34:50operator and we can us use this symbol
  932. 34:53of basically these two Pacman try need
  933. 34:54each other or just the keyword not and
  934. 34:57specifies that it's not equal to All
  935. 35:00Right Moving in back into the data let's
  936. 35:02say we're get this data right here and
  937. 35:04we want to filter it further let's say I
  938. 35:06have some Insider information that says
  939. 35:09those jobs that we get from the job
  940. 35:12platform AI Tech jobs.net is unreliable
  941. 35:15and I don't want to use it that's not
  942. 35:16necessarily true we're just giving it an
  943. 35:18example here well I conclude that wear
  944. 35:20keyword along with job via and that
  945. 35:23comparison operator of not equal to
  946. 35:26providing it what statement I want I
  947. 35:27meet on and then press control enter I
  948. 35:30can now see that they are removed now we
  949. 35:33can also use that not operator and
  950. 35:35that's used directly after the where
  951. 35:38keyword where not job via uh AI jobs.net
  952. 35:42this is sort of confusing but this in
  953. 35:44this case is going to rep return all the
  954. 35:47job Vias of this so in this case if we
  955. 35:49wanted to not use it I'd put that equal
  956. 35:52comparison operator in there run it and
  957. 35:55then we can see that it now has this
  958. 35:57like like this so not is a way to do
  959. 36:00basically opposite of what we want to do
  960. 36:02now besides something like the equal or
  961. 36:03not equal to operator for those that
  962. 36:06have numerical columns we can use things
  963. 36:08like greater than or less than to
  964. 36:11actually look inside of there and find a
  965. 36:13value and find things that meet that
  966. 36:15condition so in this case I'm going to
  967. 36:17filter for salaries that are going to be
  968. 36:19only greater than 50,000 it's also going
  969. 36:22to remove these null values whenever I
  970. 36:24do this pressing control enter and see
  971. 36:26that it is in Factor move in case like
  972. 36:29this I would include something like an
  973. 36:30order buy for that salary year average
  974. 36:33and I did this out of order uh because I
  975. 36:35don't have these memorized and putting
  976. 36:38this in after the wear statement and
  977. 36:40actually running it it runs correctly
  978. 36:43and now we can see okay now they are
  979. 36:45ordered in this order and it's starting
  980. 36:47at that 50,000 in this case now you're
  981. 36:49not just limited to greater than or
  982. 36:51equal to also you have things like less
  983. 36:52than or equal to I'm assume you have
  984. 36:54familiar RT with how this actually works
  985. 36:56so we're going to skip an example on
  986. 36:57that one
  987. 36:58and we're going to move into logical
  988. 37:00operators now starting with the first
  989. 37:01logical operator and this is great in
  990. 37:04conditions where we want to meet
  991. 37:05multiple filter conditions so the
  992. 37:08example shown if I want to meet a
  993. 37:10certain salary and job title I can now
  994. 37:12use the and operator to combine this in
  995. 37:15this case it's only going to show
  996. 37:17conditions where both of those
  997. 37:20conditions met are equal to true so it
  998. 37:23has to have a job title of data analyst
  999. 37:26and it has to have a salary greater than
  1000. 37:29100,000 so let's actually test this
  1001. 37:31query out by plugging that in for that
  1002. 37:33wear and specifying those two conditions
  1003. 37:36I'm also going to leave in that order bu
  1004. 37:38after this so we can read it more easily
  1005. 37:41pressing control enter we now have it
  1006. 37:44now remember it's greater than 100,000
  1007. 37:46not greater than or equal to so we don't
  1008. 37:48have any 100,000 values in this and
  1009. 37:50scrolling through we can see that like
  1010. 37:52we expect it Returns the conditions that
  1011. 37:54we're trying to meet for this now
  1012. 37:56conversely to that and logical operator
  1013. 37:59we also have the or logical operator and
  1014. 38:02this would be used in a condition where
  1015. 38:03we wanted to see if we meet any of the
  1016. 38:07conditions so as the example shows it
  1017. 38:09could be either data analyst or the
  1018. 38:12salary is greater than 100,000 so we
  1019. 38:16could have something like a business
  1020. 38:18analyst that gets greater than 100,000
  1021. 38:20or we could have something like a DAT
  1022. 38:21analyst that technically has less than
  1023. 38:23100,000 replacing that and with an or
  1024. 38:26and then still keep that order by so we
  1025. 38:28can get through this quickly I'm going
  1026. 38:30to press controll enter and as we can
  1027. 38:34see we have nothing but data analyst
  1028. 38:36positions for the null values and for
  1029. 38:40values that are greater than $100,000 in
  1030. 38:43salary we have everything that's not
  1031. 38:45necessarily a data analyst it could be a
  1032. 38:47data analyst and here's one at 225,000
  1033. 38:50so an or condition I'll be honest I
  1034. 38:52don't use or as much as the and logical
  1035. 38:55operator now let's say I wanted to
  1036. 38:57search for salaries between 100,000 and
  1037. 39:01200,000 technically I could use that and
  1038. 39:04operator combined with those logical
  1039. 39:06operators to say hey I want something
  1040. 39:08that's $100,000 or greater than $100,000
  1041. 39:11and less than
  1042. 39:13$200,000 but there's actually a better
  1043. 39:15way of doing this and that's using the
  1044. 39:18between logical operator it's still
  1045. 39:20going to be used within that wear
  1046. 39:22statement in this case it's much more
  1047. 39:24readable and much more concise we can
  1048. 39:26say for a given column we want between
  1049. 39:3060,000 and 990,000 in this case and this
  1050. 39:33is not just limited to numerical data
  1051. 39:35you can also technically use this for
  1052. 39:36Text data or even dates so I've updated
  1053. 39:38that previous query now to have that
  1054. 39:40between statement specifying the values
  1055. 39:43and using that and statement to join it
  1056. 39:45I'm still doing that order bu to make it
  1057. 39:46easy to look at pressing control enter
  1058. 39:49bam we have everything between including
  1059. 39:52that of which is 100,000 and 200,000 now
  1060. 39:56the last logical oper to cover is in and
  1061. 40:00this I find is more common in Text data
  1062. 40:03so the example shown job location if I
  1063. 40:06wanted to search maybe Boston
  1064. 40:08Massachusetts and also anywhere I could
  1065. 40:11do this with an instatement and then I
  1066. 40:12would enclose all those values whether
  1067. 40:15it's two or even more so let's say in
  1068. 40:17our case we wanted to look for both data
  1069. 40:20analyst jobs and also data engineer jobs
  1070. 40:23written currently it's a little bit too
  1071. 40:26robust in this too much wording as we're
  1072. 40:29repetitive with using job title short
  1073. 40:31and then combining it with that or
  1074. 40:33statement it does however if we went
  1075. 40:35ahead and execute it we can see that yep
  1076. 40:37data engineers and data analysts are
  1077. 40:39only in this but instead I'm going to
  1078. 40:41modify this now to include this in
  1079. 40:44logical operator and then have data
  1080. 40:46analyst and data Engineers within
  1081. 40:47parentheses separated by a comma and
  1082. 40:50this is also great because now let's say
  1083. 40:52I wanted to add something else like a
  1084. 40:54data scientist I can just add that in I
  1085. 40:58don't have to type in the keyword again
  1086. 41:00pressing control enter you can see now
  1087. 41:02we have data Engineers data analysts and
  1088. 41:04data scientist all right now it's your
  1089. 41:06turn to try out these comparison and
  1090. 41:08logical operators for those that have
  1091. 41:10purchased the course notes and
  1092. 41:11certificates you have a host of
  1093. 41:13different practice problems you can work
  1094. 41:15through and test your skills for that
  1095. 41:17all right see you in the next
  1096. 41:22one all right let's actually combine
  1097. 41:24everything we've learned from that basic
  1098. 41:26section and the comparison logical
  1099. 41:28operator section into a more advanced
  1100. 41:30query we're going to do this with a
  1101. 41:32practice problem that I feel would be
  1102. 41:34applicable if I was actually job
  1103. 41:36searching so let's say I'm looking for
  1104. 41:38roles I work as a data analyst and I
  1105. 41:41could technically also work as a
  1106. 41:42business analyst so I want to look for
  1107. 41:43both of these rules and for this though
  1108. 41:45I have some conditions for data analyst
  1109. 41:47I only want to search for jobs that are
  1110. 41:49greater than 100,000 and I know from
  1111. 41:52some market research business analyst
  1112. 41:54pays even less so I want to look for
  1113. 41:56those jobs that are greater than 70,000
  1114. 41:59now in addition to this I also only want
  1115. 42:01to include locations in we'll say that
  1116. 42:04I'm located in Boston Massachusetts or I
  1117. 42:07want any remote works I'll also include
  1118. 42:09any of those that include the location
  1119. 42:11of anywhere which are remote jobs for
  1120. 42:13this we're going to continue to include
  1121. 42:15those four main columns that we
  1122. 42:16previously did so starting out with our
  1123. 42:19core query we have our select statement
  1124. 42:21of the four Columns of Interest we're
  1125. 42:23want to focus on and then our from
  1126. 42:25statement whenever I'm breaking a these
  1127. 42:26queries down I like to actually iterate
  1128. 42:29through it so the first thing I'm going
  1129. 42:30to look for and actually query down on
  1130. 42:33is the location CU that seemed like the
  1131. 42:35easiest I want to get Boston and I want
  1132. 42:37to get anywhere so I add this wear
  1133. 42:40statement for this job location and
  1134. 42:43executing the query control enter we can
  1135. 42:45see now okay we're limited only anywhere
  1136. 42:47in Boston all right the next easiest
  1137. 42:49thing to move on to is instead of just
  1138. 42:52getting both that analyst and business
  1139. 42:54analyst let's actually go down even
  1140. 42:56further I want to get data analysts that
  1141. 42:58are greater than 100,000 so I also have
  1142. 43:01to besides meeting the job locations I
  1143. 43:02have to meet this new condition now I'm
  1144. 43:05going to be putting both the job title
  1145. 43:08and then also the salary condition
  1146. 43:10within this so I can use parentheses to
  1147. 43:14say hey I want you to meet all of this
  1148. 43:18and verify this before moving on to
  1149. 43:20verifying the and statement and what do
  1150. 43:22I mean by that well you remember by our
  1151. 43:24order of operations uh from math
  1152. 43:27the parentheses are going to go first so
  1153. 43:30we're going to meet the condition first
  1154. 43:31of is a de analyst and is it greater
  1155. 43:34than $100,000 are both these commission
  1156. 43:37conditions met it's true and then in the
  1157. 43:40next case it's going to check the job
  1158. 43:42locations whether it's in Boston
  1159. 43:44Massachusetts or anywhere so the
  1160. 43:46parentheses help control this order now
  1161. 43:49remember we also want to meet this
  1162. 43:51condition of business analysts and
  1163. 43:53salary year average greater than 8
  1164. 43:56$80,000 so I can remove this comment
  1165. 43:58here now I could put an or statement
  1166. 44:01after this so we me this data analyst or
  1167. 44:04this one but now we have this statement
  1168. 44:08we're going to meet and job location and
  1169. 44:11this statement and then it's going to be
  1170. 44:13an or for this one so if I were to
  1171. 44:14execute this because of this or
  1172. 44:17statement now I have this business
  1173. 44:20analyst right here and it's in D Texas
  1174. 44:23and it doesn't meet our condition
  1175. 44:25because I actually wanted it to be
  1176. 44:26either in Boston or anywhere although it
  1177. 44:29does meet our salary condition anyway
  1178. 44:30I'm going to fix this by including this
  1179. 44:33or statement now between the data
  1180. 44:35analyst and the business analyst in its
  1181. 44:38own parentheses to further specify hey I
  1182. 44:41want you meet these two end conditions
  1183. 44:43or these two end conditions then from
  1184. 44:45there once that's met then verify the
  1185. 44:47job location let's check this out and
  1186. 44:49now we have everything we want looks
  1187. 44:51like I have a typo here I did 880,000
  1188. 44:53earlier I meant to say 70,000 from our
  1189. 44:56instructions we had 61 oh now we have 64
  1190. 44:59jobs available anyway this me you the
  1191. 45:01condition of those data analyst or even
  1192. 45:04business analysts anywhere with our
  1193. 45:06salary conditions the key thing to
  1194. 45:09understand from this is you have to
  1195. 45:11iterate through this query I wouldn't
  1196. 45:13never expect you to just write this out
  1197. 45:16all in one shot and then try and test it
  1198. 45:19you're going to run into so many errors
  1199. 45:21iteration is the key to success for this
  1200. 45:28all right in this section we're going to
  1201. 45:29be covering wild cards and wild cards
  1202. 45:32are used to substitute one or more
  1203. 45:34characters within a string we can use
  1204. 45:38this by one using this keyword of like
  1205. 45:41along with some special operators like
  1206. 45:43the percentage sign and underscore oh
  1207. 45:46and all this is used within the wear
  1208. 45:47Clause let's jump into some examples and
  1209. 45:49the first wild card to cover is the
  1210. 45:51percent sign which in this case shown
  1211. 45:54here we're searching for analyst and
  1212. 45:57this percent sign symbolizes zero one or
  1213. 46:01more characters so let's say I add some
  1214. 46:02white space or some words before analyst
  1215. 46:05or after it would account for that and
  1216. 46:07only look for those words of analyst all
  1217. 46:10right so previously we've been focusing
  1218. 46:11on a job title short column and this is
  1219. 46:14just a shorten version when we actually
  1220. 46:16look at these job postings more in
  1221. 46:18detail we get to it further we'll see
  1222. 46:20that the actual job title and a list in
  1223. 46:22these is a lot longer and sometimes
  1224. 46:25there's a lot of fluff and necessary
  1225. 46:27data in it but it could be a condition
  1226. 46:30for this where we want to actually
  1227. 46:31filter down on something so in this case
  1228. 46:34we have this business data analyst and
  1229. 46:37also data analyst let's say we actually
  1230. 46:39wanted to filter down for anything that
  1231. 46:41says analyst within the job title column
  1232. 46:44well adding this wear statement and then
  1233. 46:47specifying the column using that like
  1234. 46:49keyword and then I can put that as
  1235. 46:51percentage signs before and after
  1236. 46:55running this now every in this job title
  1237. 46:59has analyst within it now it's important
  1238. 47:02to understand right I would want it
  1239. 47:04before and after let's say I removed it
  1240. 47:05to the ending in that case it's not
  1241. 47:08going to find anything with values after
  1242. 47:10the analyst so if I run this I'm only
  1243. 47:13going to find analyst on the end of all
  1244. 47:16those statements and I want to add that
  1245. 47:19back because I actually want to see all
  1246. 47:20the different analyst rules now another
  1247. 47:22way this could be used is let's say in
  1248. 47:25this case right here where I have this
  1249. 47:27it's classified as a data analyst but
  1250. 47:29the job title is business data analyst I
  1251. 47:32could put something instead let's say I
  1252. 47:33wanted to search for business analyst
  1253. 47:35roles I could put in business percent
  1254. 47:38sign and then oops that's not a percent
  1255. 47:40sign and then analyst running this now
  1256. 47:45I'll get things like that will meet the
  1257. 47:47business data analyst that may be
  1258. 47:49categorized as dat analyst maybe
  1259. 47:51categorized as a business analyst but it
  1260. 47:53picks it up now the percent sign
  1261. 47:54symbolizes 01 or more characters let's
  1262. 47:58say I just wanted to represent a single
  1263. 48:01space in between something in that case
  1264. 48:03I would use an underscore going back to
  1265. 48:06in our example instead of having this
  1266. 48:08percent sign here I'll put an underscore
  1267. 48:10in this case I only want to find those
  1268. 48:12that directly say business analyst so
  1269. 48:15I'll expect to see this one in there
  1270. 48:16whenever I run this query pressing
  1271. 48:18control enter yep 343 I can see that
  1272. 48:21anything has business space analyst I
  1273. 48:23meet this along with anything on the
  1274. 48:26left and right using the that percentage
  1275. 48:28sign all right now it's your turn to go
  1276. 48:30ahead and try this like keyword along
  1277. 48:32with testing out those different Wild
  1278. 48:35Card operators of the percent sign and
  1279. 48:37underscore those that paid for the
  1280. 48:39course certificate and notes you have
  1281. 48:40some practice problems you can work
  1282. 48:41through all those that don't feel free
  1283. 48:43to just try out and see how this
  1284. 48:45actually tests out for these different
  1285. 48:46wild cards all right see you in the next
  1286. 48:53one all right this short section is on
  1287. 48:55aliases and and I can relate to this cuz
  1288. 48:58sometimes I want to be a different
  1289. 48:59person and sometimes even column names
  1290. 49:01want to be different names this can be
  1291. 49:04very helpful especially when working
  1292. 49:05with other people to pass off data with
  1293. 49:07these really convoluted column names you
  1294. 49:10can rename it before giving it to them
  1295. 49:12so let's say I want to use this table
  1296. 49:14this core table that we've been querying
  1297. 49:16from the get-go in a presentation and I
  1298. 49:19don't want to have this as you can see a
  1299. 49:21lot of it starts with job which is sort
  1300. 49:23of redundant and then it's just the
  1301. 49:25nameing conventions are just really
  1302. 49:27weird well at least weird for somebody
  1303. 49:28that's not familiar with this database
  1304. 49:30somebody that's not familiar with this
  1305. 49:32database just wants the quick
  1306. 49:33information about what it is real quick
  1307. 49:35so I can go through and add these as
  1308. 49:37statements after these column titles
  1309. 49:40right here and then they're now rename
  1310. 49:43this running this query right now
  1311. 49:45pressing control enter I can see all of
  1312. 49:47them are renamed now as or alas can also
  1313. 49:50be used not only for column names but it
  1314. 49:53can also be used for tables and
  1315. 49:56frequently you will see whenever people
  1316. 49:58post abbreviations for tables they'll
  1317. 50:00use a single letter or multiple letters
  1318. 50:02at the start of the table so in this
  1319. 50:04case I'm renaming it JPC and then if I
  1320. 50:07wanted to although not required in this
  1321. 50:09case I could put it at the front of
  1322. 50:12these different tables right here and
  1323. 50:15when I execute this query still going to
  1324. 50:17work now we haven't gotten into joining
  1325. 50:19multiple tables and whenever you do this
  1326. 50:21is a very common practice so I wanted to
  1327. 50:24make sure that you're aware of it before
  1328. 50:25we get to that so we're going to be
  1329. 50:27doing that now the one last thing to
  1330. 50:29note on this is sometimes you'll read
  1331. 50:31other people's syntax especially when it
  1332. 50:33comes to tables they won't necessarily
  1333. 50:36put this as keyword in there instead
  1334. 50:39they're just going to have a space in
  1335. 50:40between the two and it's still whenever
  1336. 50:42I go to execute this it's going to go
  1337. 50:44ahead and work you can also do this for
  1338. 50:47these keywords in here but this I argue
  1339. 50:49makes it hard to read but you will
  1340. 50:52frequently see in this case here you
  1341. 50:54will see it done without that as key
  1342. 50:56keyword all right now it's your turn to
  1343. 50:58try out aliases I have a practice
  1344. 51:00problem for you to go and try out feel
  1345. 51:02free to experiment around not only with
  1346. 51:04those column names but also those table
  1347. 51:05names all right see you the next
  1348. 51:10one all right let's now combine what we
  1349. 51:13just learned with wild cards and also
  1350. 51:15that alias in order to solve a problem I
  1351. 51:18want to continue to build on that last
  1352. 51:19problem that we're looking for data
  1353. 51:22analyst or business analyst roles but
  1354. 51:24also we're looking for those that are
  1355. 51:26not senior additionally we'll make
  1356. 51:29aliases for the columns but they don't
  1357. 51:30make sense now before I attack a SQL
  1358. 51:32problem like this I like to break it
  1359. 51:35down further into what are the actual
  1360. 51:37steps that I need to look for for this
  1361. 51:40so what's common among this is or what's
  1362. 51:42not common among this is we want to look
  1363. 51:44for data or business in it so that's
  1364. 51:47going to be using basically an or
  1365. 51:48statement we do want to look for the
  1366. 51:50word analyst in there and then we don't
  1367. 51:53want to include things like senior so
  1368. 51:57let's jump in the and try it out all
  1369. 51:59right so here's the core query that
  1370. 52:00we're going to be working with I'm going
  1371. 52:02to go ahead and start with Alias this
  1372. 52:03first I just rename the location as
  1373. 52:06location and salary is salary so let's
  1374. 52:09just start attacking each one of these
  1375. 52:11filters one at a time and once again
  1376. 52:13we're going to be needing to use that
  1377. 52:15wear keyword the first one we're going
  1378. 52:17to be looking at is we're going to look
  1379. 52:19at only job tells that include either
  1380. 52:21data or
  1381. 52:23business so I built this or statement
  1382. 52:26now that captures that of matching the
  1383. 52:28data or business and anytime we want to
  1384. 52:30iterate through this to make sure that
  1385. 52:31we're on the right track press control
  1386. 52:33enter it looks like okay we got Data
  1387. 52:35Business data Data Business okay so it
  1388. 52:39looks like we're on the right track now
  1389. 52:40we want to include anything that would
  1390. 52:43be basically data analyst or business
  1391. 52:45analyst so we want to meet this or
  1392. 52:48condition and then basically the analyst
  1393. 52:51is an and condition so what I'm going to
  1394. 52:52do is actually wrap this in parentheses
  1395. 52:56cuz this is is the or state we want to
  1396. 52:57meet and then from there I'm going to go
  1397. 53:01in and put in the one about the
  1398. 53:06analyst all right so now we have the
  1399. 53:08analyst one executing this one looks
  1400. 53:10like now I have anything that has
  1401. 53:12business or data along with analyst in
  1402. 53:16it all right so finally this last one
  1403. 53:18don't include any Jes with senior
  1404. 53:20followed by the character so this would
  1405. 53:22be another and statement here and we're
  1406. 53:25going to be still searching job
  1407. 53:27title and for this one we don't want to
  1408. 53:30use that is like senior we want to match
  1409. 53:34basically a not condition and so for
  1410. 53:37this we can put not right before like to
  1411. 53:40say not like this um do we have any
  1412. 53:43seniors in here oh we got this one right
  1413. 53:45here so let's see if this one's still
  1414. 53:47here after we refresh this
  1415. 53:51query and Yep looks like it was taken
  1416. 53:54away so we're meeting all those
  1417. 53:55conditions all right all right we got a
  1418. 53:56query now let's jump into learning some
  1419. 53:59more about
  1420. 54:05operations all right let's get now into
  1421. 54:07operations or more specifically
  1422. 54:10arithmetic operations we'll be using
  1423. 54:12operators for this like addition
  1424. 54:14subtraction and even things like modulus
  1425. 54:17and for this we're going to be using the
  1426. 54:18invoice database which is located at
  1427. 54:20this URL as a reminder this is a
  1428. 54:22fictitious data set on data science invo
  1429. 54:26voices throughout the year of 2023 we're
  1430. 54:29using it for this because this these
  1431. 54:30columns that it has in it are really
  1432. 54:33good for doing arithmetic operations on
  1433. 54:35now we have a column specifically on
  1434. 54:37hourly rate assigned to a specific data
  1435. 54:41nerd in this data set and let's say that
  1436. 54:44our accounting department is actually
  1437. 54:45trying to figure out whether they should
  1438. 54:48raise these rates or lower these rates
  1439. 54:51so we need to provide them with a data
  1440. 54:53set with these updated rates well we can
  1441. 54:55use something like subtraction ction or
  1442. 54:57even something like addition in order to
  1443. 55:00increase that rate we can use this
  1444. 55:03within the select statement so this is
  1445. 55:05the core query we're going to be working
  1446. 55:06with in this case and we want to see
  1447. 55:10what would be the hourly rate if we say
  1448. 55:12dropped it by $5 or if we raised it by
  1449. 55:15$5 so to make sure I'm doing this
  1450. 55:17operation correct first I keep that core
  1451. 55:21one that we want to change in here still
  1452. 55:23and I'm going to rename that as rate
  1453. 55:25original then from there all I'm doing
  1454. 55:27is I have this hours rate and a minus5
  1455. 55:31and that's going to go through in every
  1456. 55:33single column subtract five and then I'm
  1457. 55:35renaming this as the rate drop so let's
  1458. 55:38actually execute this so we can see now
  1459. 55:41that it's going through and it's
  1460. 55:43executed this for a rate drop
  1461. 55:45subtracting all these different columns
  1462. 55:47by five conversely I can add this last
  1463. 55:49statement here for the rate hike of
  1464. 55:52adding $5 and we have that now of now
  1465. 55:56this band or whatever we have this whole
  1466. 55:58table made we can send this all to
  1467. 55:59accounting for them to Crunch their
  1468. 56:00numbers now I demonstrated this
  1469. 56:03operation use inside of the select
  1470. 56:05statement but we're not just limited to
  1471. 56:07that it can be used in a whole host of
  1472. 56:09keywords including things like the wear
  1473. 56:11order by and group by that we've used
  1474. 56:13previously and even more that we're
  1475. 56:15going to use in the future so let's
  1476. 56:17actually look at a case of how we can
  1477. 56:19use this even outside of that select
  1478. 56:21statement and for this we're going to be
  1479. 56:22using the multiplication operator
  1480. 56:25figuring out
  1481. 56:26basically a total pay using hour spent
  1482. 56:29times an hourly rate so going back to
  1483. 56:32that core query that we have let's say
  1484. 56:34that accounting comes back now and they
  1485. 56:36say hey we want to only have the
  1486. 56:38projects that are going to cost a total
  1487. 56:42of $1,000 and more after the rate hike
  1488. 56:45and this project total after the hike is
  1489. 56:48going to be equal to that rate hike
  1490. 56:51times those hours spent we don't have
  1491. 56:54hours spent right now so I'm actually
  1492. 56:56add add that here so we can see it pring
  1493. 56:59control enter got now the hour spent
  1494. 57:02we're going to do it times the rate hike
  1495. 57:04I'm also going to remove this rate drop
  1496. 57:06because we're not concerned with that
  1497. 57:07right now okay so we want a filter for
  1498. 57:10this so we're going to make a wear
  1499. 57:13statement and we want this where the
  1500. 57:15rate hike times that hour spent is going
  1501. 57:18to be meet this condition of greater
  1502. 57:20than 1,000 okay executing this query
  1503. 57:24looks like it's going through usually I
  1504. 57:26like to double check something like this
  1505. 57:28whenever I'm doing a calculation so I'm
  1506. 57:30going to go ahead and add this up here
  1507. 57:32where I have this rate hike of hours
  1508. 57:34rate plus 5 times hour spent as the
  1509. 57:37project total go ahead and execute this
  1510. 57:39to actually see what it is and scrolling
  1511. 57:41over can see that hey yep everything
  1512. 57:44here looks like it's greater than a
  1513. 57:46th000 now as a best practice I want to
  1514. 57:49go ahead since it's defined here replace
  1515. 57:52it down here and then now executing it
  1516. 57:56we still have the same thing and it's
  1517. 57:58more concise and easier to read all
  1518. 57:59right next up is the modulus operator
  1519. 58:02and this operator is used to return the
  1520. 58:06remainder available after a division
  1521. 58:09specifically let's say we have a number
  1522. 58:11of hours say something like 10 if we
  1523. 58:13wanted to find out how many hours past
  1524. 58:16eight that they worked we could take 10
  1525. 58:20and do the modulus of eight and this
  1526. 58:23would give us two that's showing that
  1527. 58:25somebody worked worked 2 hours past this
  1528. 58:28so let's say that accounting comes back
  1529. 58:29to us and they want to do some analysis
  1530. 58:32mainly on projects that take between one
  1531. 58:34in 2 days they want to find all the
  1532. 58:36projects that don't necessarily exactly
  1533. 58:38end within 8 hours or 16 hours so the
  1534. 58:42modulus so the first thing I want to do
  1535. 58:44is actually visualize this and see what
  1536. 58:46this is going to look like so pressing
  1537. 58:48control enter I have now this hour spent
  1538. 58:51modulus 8 and assigned to this extra
  1539. 58:53hours scrolling over a little bit just
  1540. 58:56to double check my work we can see that
  1541. 58:58at whenever it's 14 we would expect 8
  1542. 59:02goes into 14 once and then it has a
  1543. 59:04remainder of six so accting wants to
  1544. 59:07analyze these where these conditions are
  1545. 59:09true or where the modulus is not
  1546. 59:11necessarily zero so from here I can just
  1547. 59:14put this wear statement into parenthesis
  1548. 59:17at an end and then from there Define
  1549. 59:20when extra hours are basically not equal
  1550. 59:22to zero or greater than zero and we got
  1551. 59:26it all right now it's your turn to give
  1552. 59:28it a try we have some practice problems
  1553. 59:30for those that purchase course
  1554. 59:31certificate and notes you can go ahead
  1555. 59:32and go and try out these different
  1556. 59:34operations within the query all right
  1557. 59:37that see you in the next
  1558. 59:41one let's now get into aggregation
  1559. 59:44functions and after using those
  1560. 59:47arithmetic operators previously probably
  1561. 59:50notice that yeah it's nice to be able to
  1562. 59:52do this arithmetic operation across a
  1563. 59:54row but what happens if we want to do it
  1564. 59:56down meaning on we want to sum a row or
  1565. 59:59even count up an entire row on how many
  1566. 1:00:01values it has in it well this is where
  1567. 1:00:02aggregation functions come in we have
  1568. 1:00:04things like sum count average Min and
  1569. 1:00:06Max now I commonly use these within
  1570. 1:00:09things like the select statement but
  1571. 1:00:11they can also be used with keywords like
  1572. 1:00:14group by and also having for group by we
  1573. 1:00:17can actually aggregate depending on what
  1574. 1:00:20value is selected a certain subset in
  1575. 1:00:23order to sum it up or even average it or
  1576. 1:00:25maybe we can also use things like the
  1577. 1:00:27having function which we've been talking
  1578. 1:00:29about from the get-go and finally
  1579. 1:00:30getting introduced to which allows us to
  1580. 1:00:32actually filter data by an aggregation
  1581. 1:00:35for this portion we're going to be using
  1582. 1:00:37the job postings data set specifically
  1583. 1:00:40we're going to focus a lot of time on
  1584. 1:00:42this salary column and doing a lot of
  1585. 1:00:45aggregation methods to it and the first
  1586. 1:00:46aggregation method to talk about is sum
  1587. 1:00:49and this is a function that allows us to
  1588. 1:00:52inside the parentheses next to sum place
  1589. 1:00:54things like a column name and from there
  1590. 1:00:57it will Aggregate and actually sum up
  1591. 1:00:59all those values so if I want to sum up
  1592. 1:01:02all those average yearly salaries I
  1593. 1:01:05could do this and it also give it an
  1594. 1:01:06alias of salary sum pressing control
  1595. 1:01:09enter you can see we have over $2
  1596. 1:01:13billion worth of salary and job postings
  1597. 1:01:16here next aggregation method is count
  1598. 1:01:19and similarly to sum you're going to
  1599. 1:01:21place either a column value or in this
  1600. 1:01:23case you can always do something like a
  1601. 1:01:25specializ operator the asterisk or Star
  1602. 1:01:28to actually select all the different
  1603. 1:01:29columns so in our case say we wanted to
  1604. 1:01:32see not only what is the sum of all the
  1605. 1:01:34salaries but we also wanted to see what
  1606. 1:01:38was the count of all the different rows
  1607. 1:01:40I could do a new line sending in count
  1608. 1:01:43specifying that star symbol and then put
  1609. 1:01:45from there as count rows from here
  1610. 1:01:50pressing control enter it's going to
  1611. 1:01:52aggregate the same now I have the salary
  1612. 1:01:53on the left and then the count of all
  1613. 1:01:55the RADS on the right now I can also use
  1614. 1:01:57count in conjunction with another
  1615. 1:01:58keyword distinct in order to filter down
  1616. 1:02:02on distinct values let's say in our case
  1617. 1:02:05we want to get a distinct count of all
  1618. 1:02:07the different job title short values
  1619. 1:02:10that we have in here say count then add
  1620. 1:02:14distinct and then from there the actual
  1621. 1:02:17job title short and then I probably name
  1622. 1:02:20it something appropriately like job type
  1623. 1:02:22Turtle pressing control enter we can see
  1624. 1:02:25that we have 10 different job types now
  1625. 1:02:27besides sum and count the other major
  1626. 1:02:30types of aggregation functions are
  1627. 1:02:32average Min and Max and as you expect
  1628. 1:02:35they work all the same we're placing the
  1629. 1:02:37column value that we want to average
  1630. 1:02:39inside the parenthesis and then for
  1631. 1:02:40there it's going to provide either
  1632. 1:02:41average Min or Max so I could use that
  1633. 1:02:44average column across that salary year
  1634. 1:02:48average column and from there we're
  1635. 1:02:50going to get this pressing control enter
  1636. 1:02:53sign an Al an alias of salary average we
  1637. 1:02:55can see that the average salary inside
  1638. 1:02:57this column right now is around
  1639. 1:02:59123,000 now I can take this a step
  1640. 1:03:01further adding we on to this and then
  1641. 1:03:04from there specifying the job title
  1642. 1:03:06short column of data analyst and from
  1643. 1:03:10here pressing control enter we can see
  1644. 1:03:11that oh unfortunately that analyst the
  1645. 1:03:14average salary is little bit less than
  1646. 1:03:16the real average of uh only
  1647. 1:03:19$93,000 and if I want to see the spread
  1648. 1:03:21of the data analyst salaries I could add
  1649. 1:03:23in those Min and Max functions in order
  1650. 1:03:26actually go through and do that and
  1651. 1:03:28there we see we have a Min of 25,000 and
  1652. 1:03:30that Max of 650,000 now we saw how that
  1653. 1:03:33average salary went from
  1654. 1:03:35125,000 down to whenever we filtered it
  1655. 1:03:37just for data analyst down to around
  1656. 1:03:4090,000 so we want to dive deeper into
  1657. 1:03:42this well this is a great way of using
  1658. 1:03:44the group by keyword and this allows us
  1659. 1:03:48to specify a column of interest in this
  1660. 1:03:51case we're going to do the job title
  1661. 1:03:52short in order to now filter down
  1662. 1:03:55further and in our case actually be able
  1663. 1:03:57to see all those different job titles
  1664. 1:04:00and see where the disparity is so I'm
  1665. 1:04:02going to get rid of this where statement
  1666. 1:04:04in that case and I'm going to add Group
  1667. 1:04:07by specifying job title short column now
  1668. 1:04:11I can run this but um it does group it
  1669. 1:04:15but I don't know what these groupings
  1670. 1:04:16are so we need to add that into here so
  1671. 1:04:18I add it in at the top as Jobs pressing
  1672. 1:04:22control enter we now have this in and we
  1673. 1:04:24can now see the aage average men and Max
  1674. 1:04:27I'm going to throw in a quick order bu
  1675. 1:04:28in order to group this by the average
  1676. 1:04:31salary and as expected with that average
  1677. 1:04:34being around 125,000 we can see that
  1678. 1:04:36machine learning Engineers are middle
  1679. 1:04:38data analysts have some of the lowest
  1680. 1:04:40whereas senior data scientists and
  1681. 1:04:42Senior Engineers have some of the
  1682. 1:04:43highest now another popular keyword
  1683. 1:04:46besides Group by that need have inol
  1684. 1:04:47belt is having and having allows us to
  1685. 1:04:51use an aggregation method to then filter
  1686. 1:04:54by unfortunately this one my complaints
  1687. 1:04:56were sequel where you should be able to
  1688. 1:04:58do this inside of the wear keyword but
  1689. 1:05:00it doesn't allow it so let's say we want
  1690. 1:05:02to only analyze this further but for job
  1691. 1:05:06postings that have basically a certain
  1692. 1:05:08amount of values if I insert into here I
  1693. 1:05:10want to find out how many actual counts
  1694. 1:05:13of these different jobs they have first
  1695. 1:05:15so we're going to add that into here so
  1696. 1:05:17I've added this job count column in here
  1697. 1:05:19to basically total up how many there are
  1698. 1:05:20in there all right so actually looking
  1699. 1:05:22into this list further we see we have
  1700. 1:05:24quite a bit for some of these but then
  1701. 1:05:26something like Cloud engineer we don't
  1702. 1:05:29really have a lot of values in it and it
  1703. 1:05:32may be skewing the data so let's say we
  1704. 1:05:34want to exclude anything that has less
  1705. 1:05:35than a job count of 100 well we can
  1706. 1:05:38insert a having keyword and this needs
  1707. 1:05:40to go between group buy and Order buy
  1708. 1:05:44and I can specify it in this case hey we
  1709. 1:05:46want to do this for the count of job
  1710. 1:05:47ties shorts that are greater than 100
  1711. 1:05:50pressing control enter that cloud
  1712. 1:05:52engineer disappears is no longer one of
  1713. 1:05:55our problems
  1714. 1:05:56now you may be like luk can't we just
  1715. 1:05:57use a we using this job count cuz it's
  1716. 1:06:00no longer using this aggregation
  1717. 1:06:01function well removing this having
  1718. 1:06:04function right here and then keeping in
  1719. 1:06:06that we when I actually go to run this I
  1720. 1:06:08get this error there's a misuse of
  1721. 1:06:10aggregate count you can't use it inside
  1722. 1:06:12of wear it's still trying to do this
  1723. 1:06:14aggregation inside the wear that's what
  1724. 1:06:16we have to use having all right now it's
  1725. 1:06:17your turn to dive in and try some of
  1726. 1:06:19these practice problems we have for
  1727. 1:06:20aggregation functions for those that
  1728. 1:06:22purchase the course certificates and
  1729. 1:06:23notes a lot of different ones to test
  1730. 1:06:25out and try and go through all right
  1731. 1:06:27that see you in the next
  1732. 1:06:32one let's get into a practice problem
  1733. 1:06:34combining what we've learned previously
  1734. 1:06:38with the aggregation functions and also
  1735. 1:06:40with those arithmetic operations
  1736. 1:06:42specifically we're going to be going
  1737. 1:06:43back to that previous problem where I
  1738. 1:06:45was talking about the accounting
  1739. 1:06:46department asking for us to provide
  1740. 1:06:49numbers around what would happen if we
  1741. 1:06:51would increase the hourly rate by $5 and
  1742. 1:06:55so for for this we're going to calculate
  1743. 1:06:56not only the total earnings for a
  1744. 1:06:59project but then also a theoretical
  1745. 1:07:02situation of what would happen if we
  1746. 1:07:04increased it by $5 so previously we were
  1747. 1:07:07taking that hourly rate displaying it as
  1748. 1:07:09that rate original and then also doing
  1749. 1:07:11the additional 5 to show that rake hike
  1750. 1:07:14right now I also have that project ID
  1751. 1:07:16right there conveniently that we're
  1752. 1:07:17going to be breaking it down further by
  1753. 1:07:19so let's first go at tackling that first
  1754. 1:07:21problem of calculate the total earnings
  1755. 1:07:23per project which we're going to be
  1756. 1:07:24using our spent times hours rate here
  1757. 1:07:27I'm going to first start by just adding
  1758. 1:07:28in that hour spent because I want to
  1759. 1:07:29keep track of it to make sure I do the
  1760. 1:07:31calculations right from there I'm going
  1761. 1:07:33to use the sum function in order to sum
  1762. 1:07:36up the hour spent times that hourly rate
  1763. 1:07:40I'm going to rename this project
  1764. 1:07:42original cost from here I'm going to
  1765. 1:07:44iterate through this so I'm going to add
  1766. 1:07:46this up right now now there's a mistake
  1767. 1:07:48in my SQL query if you haven't caught it
  1768. 1:07:50yet as you can see we should have
  1769. 1:07:52multiple different project IDs right
  1770. 1:07:54we're trying to sum it based on that
  1771. 1:07:55project idea that's at least that's what
  1772. 1:07:57we want so we need to put a group ey in
  1773. 1:07:59there and now I'm specifying project ID
  1774. 1:08:02doing this bam I have this for all the
  1775. 1:08:05different project IDs and doing some
  1776. 1:08:07rough math that you always should do
  1777. 1:08:08whenever doing any of these queries to
  1778. 1:08:10make sure it's doing correct looks like
  1779. 1:08:12it's doing that hour spent times rate
  1780. 1:08:13original to get that project original
  1781. 1:08:15cost now I add in this for that
  1782. 1:08:18projection of what it's going to be if
  1783. 1:08:20we were to increase that hourly rate by
  1784. 1:08:23$5 and putting it within that sum
  1785. 1:08:25function and then labeling it as a
  1786. 1:08:27project projected cost now with this we
  1787. 1:08:30can actually see it but there's a lot of
  1788. 1:08:32data here I'm going to go ahead and
  1789. 1:08:34actually cling this up to actually make
  1790. 1:08:36it more visible and control enter now we
  1791. 1:08:40have all of the different comparisons
  1792. 1:08:42right here in here all right now it's
  1793. 1:08:44your turn to give it a
  1794. 1:08:49try this short section is going to be
  1795. 1:08:51going over null values and we previously
  1796. 1:08:54encountered n n values whenever we were
  1797. 1:08:57looking at the salary column of our job
  1798. 1:08:59posting data set and we filter filtered
  1799. 1:09:02ascending so from low to high those null
  1800. 1:09:05values appeared first a null is a field
  1801. 1:09:09with no value and that differs from
  1802. 1:09:12something like a value where it's zero
  1803. 1:09:15because that does have a value in it
  1804. 1:09:17although it is zero or when we're using
  1805. 1:09:20some sort of string character maybe in
  1806. 1:09:21it that it contains like a space that
  1807. 1:09:24still would not be a null value because
  1808. 1:09:26something is actually there taking up
  1809. 1:09:28bytes of data we're going to be using
  1810. 1:09:30this with the wear and having caused in
  1811. 1:09:32order to filter out and look at this
  1812. 1:09:33type of data so going back to that
  1813. 1:09:35previous example where we're actually
  1814. 1:09:37pulling those common columns that we
  1815. 1:09:39have then ordering it by that salary we
  1816. 1:09:42can see that said null values are
  1817. 1:09:45appearing first so we can use that we
  1818. 1:09:47keyword in order to filter this so I can
  1819. 1:09:50specify that the salary yearly average
  1820. 1:09:52is null pressing control enter yep it's
  1821. 1:09:54still null or I can change this to more
  1822. 1:09:56specifically is not
  1823. 1:09:59null all right told you this section was
  1824. 1:10:01short on null values now I do have a
  1825. 1:10:02couple practice problems for you now to
  1826. 1:10:04go in and try it out all right see you
  1827. 1:10:06next
  1828. 1:10:10one all right we're coming almost to the
  1829. 1:10:12end of this basic section on SQL queries
  1830. 1:10:16specifically we're going to be focusing
  1831. 1:10:18on this one on joins now these are the
  1832. 1:10:21four most common types of joins and
  1833. 1:10:24we're going to be diving into each one
  1834. 1:10:25of these separately talking about what
  1835. 1:10:27their use cases are and an example of
  1836. 1:10:29each so if you recall back from the
  1837. 1:10:31beginning of this video when we first
  1838. 1:10:33introduce that job posting data set well
  1839. 1:10:36the majority of the time in this section
  1840. 1:10:37we've been primarily focus on quering
  1841. 1:10:41this job postings fact table right here
  1842. 1:10:44and there's actually other tables
  1843. 1:10:46associated with this in the database and
  1844. 1:10:49right now you have access to all these
  1845. 1:10:51different tables that we just spoke
  1846. 1:10:53about inside this job
  1847. 1:10:552023 database which I go ahead here and
  1848. 1:10:59I actually just showcase each of the
  1849. 1:11:00different ones quering into it one quick
  1850. 1:11:03note you may be wondering why in general
  1851. 1:11:05would you even have these different
  1852. 1:11:07tables well in the case of that skills
  1853. 1:11:09dimensional table we can see we used a
  1854. 1:11:12skill ID to relate it and we have a
  1855. 1:11:15skills column and a type column we could
  1856. 1:11:18technically have this all of the skills
  1857. 1:11:21and type inside the jobs fact table but
  1858. 1:11:24this is going to be very
  1859. 1:11:27repetitive also in the case that we have
  1860. 1:11:29the SK skills of job table or sorry
  1861. 1:11:31skills job dim table it allows us to be
  1862. 1:11:34able to Aggregate and put in more than
  1863. 1:11:38one skill so there's multiple reasons
  1864. 1:11:40why you would actually have tables
  1865. 1:11:42external to another table so the first
  1866. 1:11:44join and by far the most popular join
  1867. 1:11:46that I find myself using is a left join
  1868. 1:11:49and what this is going to be doing here
  1869. 1:11:50is what it's trying to Showcase with A
  1870. 1:11:52and B are two separate tables and in it
  1871. 1:11:56for this it's going to whenever we use
  1872. 1:11:57this left join it will return all of the
  1873. 1:12:00contents of table a and then whatever
  1874. 1:12:03we're matching A and B on it's only
  1875. 1:12:06going to return the contents from B that
  1876. 1:12:09it matches a on so going back to quering
  1877. 1:12:11that job postings fact table I have on
  1878. 1:12:14here the job ID job title short and then
  1879. 1:12:16Company ID so we have a lot of different
  1880. 1:12:19job title shorts and I want to see what
  1881. 1:12:21the company ID or what is that company
  1882. 1:12:24it is if I want over to that company dim
  1883. 1:12:26table as we're quering it here I could
  1884. 1:12:29see what it is but it's over here I want
  1885. 1:12:31to combine it with that fact table so
  1886. 1:12:33the first thing I'm going to do is add
  1887. 1:12:34this keyword of left join and then
  1888. 1:12:37specify the table company dim have a
  1889. 1:12:40little typo right here and we're going
  1890. 1:12:43to then give it an alias I don't have to
  1891. 1:12:44type this dim every single time now in
  1892. 1:12:46addition to this we need to specify how
  1893. 1:12:49we're going to be actually connecting
  1894. 1:12:52these two tables we need to use the
  1895. 1:12:54company ID from this job posting facts
  1896. 1:12:57table to the company ID of the company
  1897. 1:13:00dim table so putting that in there and
  1898. 1:13:04then going ahead and executing it
  1899. 1:13:06they're now connected but I haven't
  1900. 1:13:07really brought anything over so now I
  1901. 1:13:09can add that column from companies now
  1902. 1:13:13remember this is why I previously talked
  1903. 1:13:15about you can put the table name in
  1904. 1:13:18front of a column and this is very
  1905. 1:13:20important to do in order to make sure
  1906. 1:13:22you're not confusing different
  1907. 1:13:26column names between the two because you
  1908. 1:13:28can see from here companies also has a
  1909. 1:13:31company ID name but more importantly we
  1910. 1:13:33want to get that company name so I have
  1911. 1:13:35it here included as name from here I'm
  1912. 1:13:37going to go ahead and press control
  1913. 1:13:39enter to load this all in and so now we
  1914. 1:13:42see we've now used this left join in
  1915. 1:13:44order to join that company name along
  1916. 1:13:47with those job titles this company ID
  1917. 1:13:50isn't really necessary at this point nor
  1918. 1:13:52did you need to actually do it from the
  1919. 1:13:53get-go I was just doing it for
  1920. 1:13:55illustrative purposes I'm going to go
  1921. 1:13:56ahead and run this and actually remove
  1922. 1:13:58it and then also going in and go in to
  1923. 1:14:01renaming those column titles okay pretty
  1924. 1:14:04cool left joins now for those that would
  1925. 1:14:06like a more illustrative view of how
  1926. 1:14:07this is being done that job postings
  1927. 1:14:10fact is that table a that we're joining
  1928. 1:14:12we're keeping all rows in it so it's
  1929. 1:14:14that yellow and then we have that
  1930. 1:14:16company's DM which is that table B in
  1931. 1:14:18our case we have all the different
  1932. 1:14:19companies available here so whenever we
  1933. 1:14:22put these two together we then have that
  1934. 1:14:24company name right available inside of a
  1935. 1:14:27results table all right and as you
  1936. 1:14:28guessed it if there's a left join
  1937. 1:14:30there's probably a right join and this
  1938. 1:14:32is going to be somewhat completely
  1939. 1:14:34opposite we're going to be basically for
  1940. 1:14:36the B table we're going to say hey we
  1941. 1:14:39want to match all the contents of this
  1942. 1:14:41and keep all the contents of this but
  1943. 1:14:43anything that matches from that a table
  1944. 1:14:45we want to join it now similarly we're
  1945. 1:14:47going to be connecting backwards we're
  1946. 1:14:49going to be connecting the company's
  1947. 1:14:51table to the job posting fact table the
  1948. 1:14:54problem is though is there's more
  1949. 1:14:56records within the job posting fact than
  1950. 1:14:58there are in the company's table so only
  1951. 1:15:01a subset of data is going to be returned
  1952. 1:15:03so going back to that illustrative
  1953. 1:15:04example from before of merging those job
  1954. 1:15:07posting facts to the company table if
  1955. 1:15:10we're using a right join in this case
  1956. 1:15:11it's going to do a very similar thing
  1957. 1:15:14now the thing to note is the company's
  1958. 1:15:16dim table only has one occurrence of
  1959. 1:15:20Netflix or meta Experian whatever it may
  1960. 1:15:23be and there's multiple in the job
  1961. 1:15:25posting facts what's going to actually
  1962. 1:15:26happen is when we get a results table
  1963. 1:15:28there's whenever we join this up we may
  1964. 1:15:31have that company appear more than once
  1965. 1:15:32now so in this case I can go ahead and
  1966. 1:15:35just replace that left one with a right
  1967. 1:15:38press control enter we'll see that we
  1968. 1:15:39have right now 33585 rows whenever I do
  1969. 1:15:42it again this one's a little bit longer
  1970. 1:15:45takes a little bit more longer time to
  1971. 1:15:47actually compile and we have it back
  1972. 1:15:50with all those previous roles so you may
  1973. 1:15:52be like Luke what's the purpose of this
  1974. 1:15:54right join then if it's basically the
  1975. 1:15:56exact opposite thing of this left join
  1976. 1:15:57well let's say for example in this case
  1977. 1:16:00if we had more companies listed in that
  1978. 1:16:03company dim table than we did in our
  1979. 1:16:06fact table itself well in this case we
  1980. 1:16:08could spot those irregularities by
  1981. 1:16:11allowing us to now do this right join
  1982. 1:16:13and ensure we are actually providing all
  1983. 1:16:16the key details of that company table so
  1984. 1:16:19although not necessarily common all the
  1985. 1:16:21time it does come up from time to time
  1986. 1:16:23so you should be aware of it all next up
  1987. 1:16:25is inter jooin what this is going to do
  1988. 1:16:27is when we have an A and B table
  1989. 1:16:29whenever we go to combine them it's only
  1990. 1:16:32going to return the contents that appear
  1991. 1:16:34in both so if there's something in a
  1992. 1:16:36that's not in b not going to appear in a
  1993. 1:16:39and not going to appear in B so let's
  1994. 1:16:40say there's a scenario where I want to
  1995. 1:16:42look at jobs but I only want to look at
  1996. 1:16:45jobs where a skill is available this is
  1997. 1:16:48where inner join is going to come in so
  1998. 1:16:50this is a fictitious making of our data
  1999. 1:16:52set but we have the job postings fact
  2000. 1:16:55table along with the job IDs and let's
  2001. 1:16:57say that this skill job dim table is
  2002. 1:17:00connected to it and let's also say it's
  2003. 1:17:02an order by that job ID there aren't any
  2004. 1:17:06necessarily skills associated with this
  2005. 1:17:08job ID of three and four so we don't
  2006. 1:17:11want to necessarily see that now this
  2007. 1:17:14combination of these two tables is a
  2008. 1:17:16single inner join in itself but as we
  2009. 1:17:19talked about earlier there's actually
  2010. 1:17:20another table so we need another inner
  2011. 1:17:22join in order to do the same thing of
  2012. 1:17:26filtering for only skills that are
  2013. 1:17:28available in this case whenever we look
  2014. 1:17:30at these skill IDs we can see that 1
  2015. 1:17:33three and two are used 1 two and three
  2016. 1:17:35which correlate to python R and SQL so
  2017. 1:17:37we're not going to return anything that
  2018. 1:17:39has Scala or Java in this case so let's
  2019. 1:17:42actually build this query out working
  2020. 1:17:44from that left to right the first thing
  2021. 1:17:45we want to do is an injoin on that skill
  2022. 1:17:48jobs Dimension table which we're going
  2023. 1:17:50to be connecting on that job ID so I
  2024. 1:17:52specify in join specifying the table
  2025. 1:17:54table of skill jobs demm I've shortened
  2026. 1:17:57that table or changed the name to skills
  2027. 1:17:58to job and then specify what I want to
  2028. 1:18:01meet it on I want to meet it on that job
  2029. 1:18:03ID of both of those pressing control
  2030. 1:18:06enter making sure that it works still
  2031. 1:18:08working and in now in this case we're
  2032. 1:18:11seeing that in the case of this job Ida
  2033. 1:18:14machine learning engineer they have
  2034. 1:18:16quite a bit and we're actually whenever
  2035. 1:18:19we get into job ID number one we skip
  2036. 1:18:22over it's no longer included because
  2037. 1:18:23apparently it does have any skills
  2038. 1:18:25associated with it so we're already
  2039. 1:18:27seeing good that we're meaning on what
  2040. 1:18:28we need to do and if I want to actually
  2041. 1:18:31see all of those different values or
  2042. 1:18:33those skill IDs that I see I can see
  2043. 1:18:35okay that's why the machine learning
  2044. 1:18:37engineer has so many and then moving on
  2045. 1:18:39to the business data analyst but we're
  2046. 1:18:41not done with this because we also want
  2047. 1:18:43to make sure that we have everything
  2048. 1:18:45only including those skills inside of
  2049. 1:18:47here that are relevant to the Javas
  2050. 1:18:49table so we want to also do an inner
  2051. 1:18:50join with this table so I'm going to go
  2052. 1:18:53ahead and add in that inter join
  2053. 1:18:56specifying the skills dim as a skills
  2054. 1:18:58table and then specifying that hey I'm
  2055. 1:19:00matching the skill ID of these tables
  2056. 1:19:03I'll also go ahead and add the skill now
  2057. 1:19:07pressing control enter to go ahead and
  2058. 1:19:09execute it bam we have now the machine
  2059. 1:19:11learning engineer with a lot of
  2060. 1:19:14different skills that it's requiring um
  2061. 1:19:16business de analyst and so on so inner
  2062. 1:19:19join along with that left join are two
  2063. 1:19:23of the most popular type typ of joins
  2064. 1:19:25that I'm going to be doing on a frequent
  2065. 1:19:26basis depending on whether I need to one
  2066. 1:19:30return all the contents of a table or
  2067. 1:19:32two for the inner join only return those
  2068. 1:19:35where it meets in both those tables the
  2069. 1:19:38last join to talk about is a full outer
  2070. 1:19:39join basically if you're going to have
  2071. 1:19:41two tables whenever we join these
  2072. 1:19:44together it's going to combine them
  2073. 1:19:45together no matter whether there are
  2074. 1:19:47matching ones on the a table or the B
  2075. 1:19:49table frankly as a data analyst I never
  2076. 1:19:52have a need for this and don't really
  2077. 1:19:54have an ex example use case for his go
  2078. 1:19:55through and I think it's sort of a waste
  2079. 1:19:57of your time so we're not going to
  2080. 1:19:58really focus on this but mainly we're
  2081. 1:20:00going to just have it in the back of
  2082. 1:20:01your mind to know that this is available
  2083. 1:20:03all right now it's your turn to give it
  2084. 1:20:04a try if you've purchased the course
  2085. 1:20:06notes and certificate you have some
  2086. 1:20:07practice problems for you to go in and
  2087. 1:20:09jump in and try out with a inner join
  2088. 1:20:11and a left join all right bet see you
  2089. 1:20:13the next
  2090. 1:20:19one as we're coming to the end of this
  2091. 1:20:21basic section there's a concept that you
  2092. 1:20:23need to be aware of of especially as you
  2093. 1:20:26become more advanced in SQL and that is
  2094. 1:20:29the order of execution of SQL queries
  2095. 1:20:32now whenever we send a SQL query via
  2096. 1:20:35this flow path right here the statement
  2097. 1:20:38itself into a database it goes through a
  2098. 1:20:40few different processes before it then
  2099. 1:20:42goes and actually is executed this
  2100. 1:20:44execution is broken down into multiple
  2101. 1:20:47steps once this is done within the
  2102. 1:20:49database itself these results come back
  2103. 1:20:51to you now if you notice we have this
  2104. 1:20:53step first of the this parser now I
  2105. 1:20:56don't want this to be confused with an
  2106. 1:20:57earlier concept that we talked about
  2107. 1:20:59that handles in the earlier steps of
  2108. 1:21:01this in between the parser and Optimizer
  2109. 1:21:03and that is the order to write commands
  2110. 1:21:06as we've talked about multiple times you
  2111. 1:21:08have to go or you have to write this
  2112. 1:21:11query syntax in a certain order you
  2113. 1:21:14can't have a where statement at the very
  2114. 1:21:15beginning has to follow that from
  2115. 1:21:17statement once our SQL query we've built
  2116. 1:21:20has meet these conditions and has gone
  2117. 1:21:22through that Optimizer it then gets into
  2118. 1:21:24into the execution phase and that's
  2119. 1:21:26where the order of this execution right
  2120. 1:21:28here is comes into importance and it
  2121. 1:21:31follows this general order that we're
  2122. 1:21:33following right here now you don't need
  2123. 1:21:35to have this order memorized mainly I
  2124. 1:21:38just remind you of this because it's
  2125. 1:21:39going to be important one day down the
  2126. 1:21:41road when you're writing a SQL query
  2127. 1:21:43well this order is actually very
  2128. 1:21:45important because from the perspective
  2129. 1:21:48of the database this ensures that it's
  2130. 1:21:50processed efficiently and logically
  2131. 1:21:51right now we're working with a
  2132. 1:21:52relatively small database and every time
  2133. 1:21:54you quer it notice it probably returns
  2134. 1:21:56it in less than a second but if you get
  2135. 1:21:58it to billions of rows of data this can
  2136. 1:22:00take seconds upon minutes and by
  2137. 1:22:03understanding this order we could
  2138. 1:22:04potentially early in this phase filter
  2139. 1:22:07down our data in order to speed up this
  2140. 1:22:10query so just keep this tool in your
  2141. 1:22:12tool belt whenever you're approaching a
  2142. 1:22:14very complex query which we're going to
  2143. 1:22:16be doing in the advanced section and
  2144. 1:22:18also within the portfolio project if we
  2145. 1:22:21need to speed up a query we're going to
  2146. 1:22:23start here by looking at at the order of
  2147. 1:22:25these and working earlier up in this
  2148. 1:22:27sequence to filter down and make our
  2149. 1:22:29data as small as possible to speed up
  2150. 1:22:32those queries all right that see you the
  2151. 1:22:34next
  2152. 1:22:38one all right let's wrap up this section
  2153. 1:22:41on the basics by doing a practice
  2154. 1:22:43problem and for this we're going to be
  2155. 1:22:45focusing on the joins in order to build
  2156. 1:22:49a more complicated query using left
  2157. 1:22:51joint specifically I'm going to find
  2158. 1:22:53something I feel that's pretty
  2159. 1:22:55interesting for a given skill I want to
  2160. 1:22:58find the number of job postings for the
  2161. 1:23:01skill itself and also the average salary
  2162. 1:23:04as expected we're going to be using that
  2163. 1:23:06left join to combine our skills table to
  2164. 1:23:09our job postings table also have a few
  2165. 1:23:11hints along the way go help us build
  2166. 1:23:13upon this process let's jump into it
  2167. 1:23:15first thing I'm going to do is query the
  2168. 1:23:18skills table or the skills dim table
  2169. 1:23:20rename a skills and then from there just
  2170. 1:23:23get back all the different skills that
  2171. 1:23:24we have available so right now we have
  2172. 1:23:27225 skills let's build upon it further
  2173. 1:23:30after now that we've gotten the skills
  2174. 1:23:32from the skill gy table I want to count
  2175. 1:23:34how many job postings mention each skill
  2176. 1:23:37from the skills to job to gym table so
  2177. 1:23:39the first thing I'm going to do is add
  2178. 1:23:40in this left join in order to go in and
  2179. 1:23:43combine that skills gy uh skills job dim
  2180. 1:23:47table which I've renamed skills to job
  2181. 1:23:49linking it on that skill ID now going to
  2182. 1:23:53that table we can see have a skill ID
  2183. 1:23:54and the job ID so with this we can get a
  2184. 1:23:58count of the jobs in there okay and we
  2185. 1:24:01have this back but we now we only have
  2186. 1:24:02it for one python because now right
  2187. 1:24:05we're using an aggregation function so
  2188. 1:24:08we need to group it so I'm going to
  2189. 1:24:09group it by the skills column and then
  2190. 1:24:11we have this along with those number of
  2191. 1:24:14job postings all right now following
  2192. 1:24:16along my plan of action we've now have
  2193. 1:24:20the skill names the number of job
  2194. 1:24:21postings I want to now calc calate the
  2195. 1:24:24average Yer salary for the job posting
  2196. 1:24:27associated with each skill so we need to
  2197. 1:24:29bring in another table in specifically
  2198. 1:24:32back to that jobs fact table in order to
  2199. 1:24:36get that salary that we need so once
  2200. 1:24:38again I do another left join bring in
  2201. 1:24:40that job posting facts importing it in
  2202. 1:24:42as job postings linking it on that job
  2203. 1:24:45ID making sure that it still executes
  2204. 1:24:47it's running fine so now we have access
  2205. 1:24:50to that average year salary so I can now
  2206. 1:24:53go ahead and add in the aggregation
  2207. 1:24:56function for that salary year average I
  2208. 1:24:59renamed it average salary for skill and
  2209. 1:25:03we'll go ahead and enter and I forgot a
  2210. 1:25:06comma so we'll go ahead and add that and
  2211. 1:25:09press control enter and Bam we got it
  2212. 1:25:13all right now anytime I get any type of
  2213. 1:25:14results like this um we pretty much have
  2214. 1:25:17gone through our entire path um but
  2215. 1:25:20anytime we get um something like this we
  2216. 1:25:22want to order it by something I find the
  2217. 1:25:25most for me I want to see it ordered by
  2218. 1:25:27salary and for this I'm going to specify
  2219. 1:25:29for the average salary for skill I'm
  2220. 1:25:31going to put it in descending order and
  2221. 1:25:33Bam there we have it actually opening
  2222. 1:25:36this up all the way this is actually
  2223. 1:25:38pretty insightful you get to see a lot
  2224. 1:25:40of these skills especially around web
  2225. 1:25:42development are more higher paying and
  2226. 1:25:45then more basic skills like something
  2227. 1:25:47like Microsoft list vb.net get out of
  2228. 1:25:51here webx are uh lower paying all right
  2229. 1:25:54sweet now it's your turn to give it a
  2230. 1:25:55try and after this this wraps up the
  2231. 1:25:59entire basic section and now we're going
  2232. 1:26:00to be moving into more advanced concepts
  2233. 1:26:03so take a second to reflect on what
  2234. 1:26:05you've learned so far you really have
  2235. 1:26:06come a long way I mean look at this we
  2236. 1:26:09just wrote a 12 line query and hopefully
  2237. 1:26:12if you're keeping up with this you
  2238. 1:26:13understand everything that's going on in
  2239. 1:26:15this that's pretty impressive all right
  2240. 1:26:17with that see you in the advanced
  2241. 1:26:19section then nerds welcome to the
  2242. 1:26:22advanced section of this course and this
  2243. 1:26:24portion will be on about what the
  2244. 1:26:26advaned sections on and more
  2245. 1:26:28specifically how we're going to be
  2246. 1:26:30setting up a database locally on your
  2247. 1:26:32computer using postgress now since we're
  2248. 1:26:35going to be have this database locally
  2249. 1:26:37you're going to be able to do a lot more
  2250. 1:26:38with this specifically going be able to
  2251. 1:26:40do things like manipulate it creating
  2252. 1:26:42altering dropping tables doing a whole
  2253. 1:26:45host of things and actually getting into
  2254. 1:26:47the core of the power of SQL now also in
  2255. 1:26:50this section we're going to be obviously
  2256. 1:26:51covering a little bit more advanced
  2257. 1:26:53topics such such as how to handle case
  2258. 1:26:55Expressions subqueries CTS and even
  2259. 1:26:57unions so it's a whole host of things
  2260. 1:27:00that I use from time to time and it's
  2261. 1:27:03who of you to know so previously in the
  2262. 1:27:05beginner section we were using inside
  2263. 1:27:07your browser sqlite viz and this
  2264. 1:27:10actually loaded inside your web browser
  2265. 1:27:13the SQL database that you were then
  2266. 1:27:15writing these queries to and executing
  2267. 1:27:17and then getting those results back now
  2268. 1:27:19this tool is great especially when
  2269. 1:27:21you're practicing and learning SQL in
  2270. 1:27:23order get it up and running quick
  2271. 1:27:25without any setup but this is not how
  2272. 1:27:28you're actually going to be interacting
  2273. 1:27:30with it in the real world so I wanted to
  2274. 1:27:32provide a scenario similar to how you're
  2275. 1:27:34going to be doing it in a real world
  2276. 1:27:36scenario so instead of using this app
  2277. 1:27:38we're going to be using popular editor
  2278. 1:27:41option VSS code and VSS code allows you
  2279. 1:27:45to track all your different SQL files
  2280. 1:27:46that you're using and then also connect
  2281. 1:27:49to a host of different SQL databases but
  2282. 1:27:52we'll get to vs code in a little b as
  2283. 1:27:55the more important thing that we need to
  2284. 1:27:56actually get installed is the database
  2285. 1:27:58itself and we're going to be using
  2286. 1:28:00postgress with this which is an easy to
  2287. 1:28:03download program which about to go
  2288. 1:28:04through and able to get it running
  2289. 1:28:06locally on your machine now as a quick
  2290. 1:28:09refresher why are we using postgress for
  2291. 1:28:11this well looking at the 2023 stack
  2292. 1:28:15Overflow survey the results from this
  2293. 1:28:18concluded that postgress is one of the
  2294. 1:28:20most popular options among developers
  2295. 1:28:23now there's a lot of other popular
  2296. 1:28:24options in the datalux community
  2297. 1:28:26especially things like MySQL SQL light
  2298. 1:28:28like you've already used and SQL server
  2299. 1:28:31and the concepts that you're learning in
  2300. 1:28:33this course regarding specifically with
  2301. 1:28:35the SQL syntax can be applied to these
  2302. 1:28:38different databases so even if you don't
  2303. 1:28:41use the number one popular option it's
  2304. 1:28:43still going to be able to have and use
  2305. 1:28:44those skills in other databases also
  2306. 1:28:47last data point I promise before we get
  2307. 1:28:49into the downloading with postest itself
  2308. 1:28:51it is topping the charts at the most
  2309. 1:28:54admired and also the most desired SQL
  2310. 1:28:57database technology that most admired
  2311. 1:28:59data point is the proportion of users
  2312. 1:29:01that use postgress and want to continue
  2313. 1:29:04to use it whereas that desired metric or
  2314. 1:29:06the blue is the proportion of
  2315. 1:29:08respondents who want to use this
  2316. 1:29:10technology and in both of these cases it
  2317. 1:29:13exceeds all of its competitors and so
  2318. 1:29:15that's why I think it's a great database
  2319. 1:29:17for you to get into all right let's get
  2320. 1:29:19into downloading postest and for this
  2321. 1:29:22you don't have to have a lot of computer
  2322. 1:29:24it doesn't take up a lot at all and so
  2323. 1:29:26you're going to navigate to this URL
  2324. 1:29:28right here or feel free to just Google
  2325. 1:29:29postgress and it will take you right
  2326. 1:29:31here anyway I'm going to click download
  2327. 1:29:33and from here we're going to select our
  2328. 1:29:34operating system of choice I have a Mac
  2329. 1:29:36right now but I've verified that the
  2330. 1:29:39installation instructions are exactly
  2331. 1:29:41the same for a Windows user so you're
  2332. 1:29:43going to follow the exact same steps now
  2333. 1:29:45I'm going to download the installer now
  2334. 1:29:47this has a few different options
  2335. 1:29:50available and also I'm not sure why you
  2336. 1:29:51had to select the operating systems at
  2337. 1:29:53the beginning cuz you're just selecting
  2338. 1:29:54it here anyway we're going to go with
  2339. 1:29:56the most current version so
  2340. 1:29:5816.2 I've done this previously on older
  2341. 1:30:00versions like 10 so don't worry if you
  2342. 1:30:02have an older version this still should
  2343. 1:30:04still work so navigate over to your
  2344. 1:30:06download folder you should have some
  2345. 1:30:07sort of installer package like this and
  2346. 1:30:10just go ahead and click on it it may
  2347. 1:30:11prompt you if you're sure you want to
  2348. 1:30:13open from the internet yeah go ahead and
  2349. 1:30:14open it now we're going to walk through
  2350. 1:30:15the setup process for a lot of these
  2351. 1:30:18things we going to be keeping it it's
  2352. 1:30:19default such as this location right here
  2353. 1:30:21and as far as installing all these
  2354. 1:30:23different packages I do want them so
  2355. 1:30:25we're going to continue once again
  2356. 1:30:26default for the data location next is
  2357. 1:30:29password and this is very important that
  2358. 1:30:31you remember this password because this
  2359. 1:30:33is going to have to be used in order to
  2360. 1:30:35access the database and even start it up
  2361. 1:30:37so if you need to write down what you're
  2362. 1:30:39going to have for your password for the
  2363. 1:30:41port number don't change it if you want
  2364. 1:30:43to change it from this 5432 make sure
  2365. 1:30:46you write it down as well for the local
  2366. 1:30:48keep default I don't know what this is
  2367. 1:30:50okay setup's not ready to install so
  2368. 1:30:52let's get to installing it all right
  2369. 1:30:54looks like it's installed and it's asked
  2370. 1:30:55if it wants to launch stack Builder
  2371. 1:30:57which can install additional modules to
  2372. 1:30:59help you out we're not going to need
  2373. 1:31:01this right now so I'm not going to
  2374. 1:31:02launch it up and I'm going unclick that
  2375. 1:31:03check mark So now let's launch postgress
  2376. 1:31:07and anytime you're wanting to actually
  2377. 1:31:09query this database that we're going to
  2378. 1:31:11be building on here you need to do this
  2379. 1:31:13so for some reason you restart your
  2380. 1:31:15computer and bring it back up you need
  2381. 1:31:17to restart postgress anyway going to
  2382. 1:31:19navigate into here this folder postgress
  2383. 1:31:21SQL 16 and go into to PG admin there's
  2384. 1:31:25the admin dashboard of how you're going
  2385. 1:31:27to control it and it's loading up so I
  2386. 1:31:30have it up and running over on the left
  2387. 1:31:33hand side this little pane is going to
  2388. 1:31:34have all your different servers and
  2389. 1:31:35database and all the configuration with
  2390. 1:31:37it and then right hand side sort of like
  2391. 1:31:38think of it like your editor where you
  2392. 1:31:40can do a bunch of configurations anyway
  2393. 1:31:43I'm going to go ahead and click this
  2394. 1:31:44open and I have an older edition of
  2395. 1:31:47postgress well databases at least on my
  2396. 1:31:49system we're not going to worry about
  2397. 1:31:51that if you only have one you should see
  2398. 1:31:53that 16 we'll go ahead and open it up
  2399. 1:31:55this is where you have to have your
  2400. 1:31:57password memorized so I'm going to go
  2401. 1:31:59ahead and put it in I'm also going to
  2402. 1:32:00click save password and then go Fed so
  2403. 1:32:03now that I've done that it's going ahead
  2404. 1:32:05and started up my databases I can see
  2405. 1:32:07this in here by navigating into
  2406. 1:32:09databases and right now there's only one
  2407. 1:32:13these are the contents of the database
  2408. 1:32:14there's only one database in there and
  2409. 1:32:16it's conveniently titled postgress
  2410. 1:32:19anyway now Beyond this inside of PG
  2411. 1:32:21admin is basically beyond the scope of
  2412. 1:32:23this course as you can come in here and
  2413. 1:32:26actually run SQL queries to thus
  2414. 1:32:28interact with your database but then
  2415. 1:32:31what happens if you want to use another
  2416. 1:32:33about database such as like MySQL or SQL
  2417. 1:32:35Server you're not going to use PG admin
  2418. 1:32:36for this so we're not going to be
  2419. 1:32:37focused on this for the remainder of
  2420. 1:32:38this course just understand that you do
  2421. 1:32:40have to launch PG admin in order to get
  2422. 1:32:43your database running with that let's
  2423. 1:32:45get into getting the code editor so we
  2424. 1:32:46can actually run some SQL
  2425. 1:32:51queries all right in this section we're
  2426. 1:32:53going to get into installing vs code
  2427. 1:32:56which going to be our code editor in
  2428. 1:32:58order to run our SQL queries now what is
  2429. 1:33:01a code editor and this is a location
  2430. 1:33:04that you can go and organize any type of
  2431. 1:33:06code you may have in our case we're
  2432. 1:33:08going to have these SQL queries written
  2433. 1:33:09out inside of a SQL file and so from
  2434. 1:33:12there we want to keep it inside of a
  2435. 1:33:13code Eder now another term to keep in
  2436. 1:33:15mind is integrated development
  2437. 1:33:17environment also known as idees Ides are
  2438. 1:33:21basically a text editor on steroids it's
  2439. 1:33:25debatable of what exactly VSS code is
  2440. 1:33:27technically it's a code editor that
  2441. 1:33:29we're going to be using but because of
  2442. 1:33:30the additions we're going to add to it
  2443. 1:33:32it functions like an IDE nonetheless the
  2444. 1:33:35terms are going to come up and I want
  2445. 1:33:36you to be aware of it so once again if
  2446. 1:33:38we go over to stack Overflow to see what
  2447. 1:33:40are the popular options among developers
  2448. 1:33:42right now Visual Studio code also spoken
  2449. 1:33:46vs code is by far the most popular
  2450. 1:33:49option on the market so that's frankly
  2451. 1:33:51why the reason why we're using it and I
  2452. 1:33:53just frankly like it in general now VSS
  2453. 1:33:55code is a code editor for a multitude of
  2454. 1:33:58languages but there are editors that you
  2455. 1:34:01can use that are specific to SQL and I
  2456. 1:34:04want you to be aware of them in case
  2457. 1:34:06down the road you want to decide to use
  2458. 1:34:07it specifically down here if we scroll
  2459. 1:34:09down data grip that's one from the team
  2460. 1:34:12over at jet Brains it's a very popular
  2461. 1:34:15option although paid and another popular
  2462. 1:34:17option that didn't make that list there
  2463. 1:34:19but I know about it from the DAT
  2464. 1:34:21analytics Community is De Beaver this is
  2465. 1:34:23is a free cross-platform database tool
  2466. 1:34:25for developers and it supports things
  2467. 1:34:28like postgress an app like this I would
  2468. 1:34:31say is actually more powerful when it
  2469. 1:34:33comes to running SQL queries as you can
  2470. 1:34:36do a lot more functionality with it in
  2471. 1:34:38regards to SQL but then if I want to run
  2472. 1:34:41other different languages such as python
  2473. 1:34:42or R I can't do it inside of this that's
  2474. 1:34:45why as me as a python user I stick with
  2475. 1:34:48vs code anyway let's get into
  2476. 1:34:49downloading and setting up visual studio
  2477. 1:34:51code so navigate to this URL right here
  2478. 1:34:55where you're going to go and then
  2479. 1:34:56download it you can download it for
  2480. 1:34:58either Mac or Windows I would get the
  2481. 1:35:01actual stable version and actually get
  2482. 1:35:03it this installation process is a lot
  2483. 1:35:05simpler as once you unzip that file that
  2484. 1:35:08it gives you in like your downloads
  2485. 1:35:09folder you'll have the app available
  2486. 1:35:11from there you'll take it and you drop
  2487. 1:35:12it into your applications folder from
  2488. 1:35:14there actually navigate into the
  2489. 1:35:16applications folder and then start this
  2490. 1:35:18bad boy up so getting into a quick
  2491. 1:35:20overview of how VSS code works
  2492. 1:35:24over on the left hand side we have our
  2493. 1:35:26activity bar and I have a few extra
  2494. 1:35:28icons right here don't worry about that
  2495. 1:35:30too much but overall I find that I'm
  2496. 1:35:32using this right here this explore and
  2497. 1:35:34this is going to display all my
  2498. 1:35:36different files on the Le hand side I
  2499. 1:35:38can also do things like search through
  2500. 1:35:40my files and then even add extensions
  2501. 1:35:42which we're going to get to in a second
  2502. 1:35:43so let's actually create this project
  2503. 1:35:45folder that we're going to be working
  2504. 1:35:46within so I'm going navigate back here
  2505. 1:35:48to the explore and click open folder I'm
  2506. 1:35:50going to navigate to wherever I want
  2507. 1:35:52this project folder to be I keep mine
  2508. 1:35:54within a developer folder and I'm going
  2509. 1:35:56to add this new folder of where we're
  2510. 1:35:58going to title it I'm title it SQL
  2511. 1:36:01project data job analysis I use
  2512. 1:36:03underscore in between this it's just for
  2513. 1:36:06coding purposes you don't have to if you
  2514. 1:36:08want to but I like to now with this
  2515. 1:36:10folder selected I'm going to select open
  2516. 1:36:13now that we're inside of this folder
  2517. 1:36:15right here titled SQL project. jobs I
  2518. 1:36:18can access or add a file by directly
  2519. 1:36:21just selecting this icon of adding a
  2520. 1:36:23file and then naming it appropriately so
  2521. 1:36:25I named this one test. SQL and that's
  2522. 1:36:28going to create a SQL file now we have
  2523. 1:36:31the file located on the right hand side
  2524. 1:36:33and this is where the editor portion of
  2525. 1:36:36it is so I just wrote some SQL code just
  2526. 1:36:39to Showcase that you can do this and
  2527. 1:36:41it's possible you may have the option
  2528. 1:36:44down here or you should have the option
  2529. 1:36:45down here to select your language mode
  2530. 1:36:47depending on what language you're using
  2531. 1:36:50you'll want it to actually check this if
  2532. 1:36:53you don't happen to see this down here
  2533. 1:36:54come down to this Bottom bar down here
  2534. 1:36:56right click it and then from there you
  2535. 1:36:58should be able to select editor language
  2536. 1:37:01anyway we want SQL for this CU we want
  2537. 1:37:03to check it to make sure that it's
  2538. 1:37:04correct if I were to select something
  2539. 1:37:06like python it's well it's not really
  2540. 1:37:09checking anything but right here it's
  2541. 1:37:11going to throw some errors now because
  2542. 1:37:13it understands with this yellow and this
  2543. 1:37:15red under statement that this isn't
  2544. 1:37:17correct python so I'm going to select
  2545. 1:37:19SQL and those errors go away anyway we
  2546. 1:37:22can write SQL now in here but the
  2547. 1:37:25problem is we don't have it connected to
  2548. 1:37:28our actual database so we need to set it
  2549. 1:37:31up to where VSS code inside of our
  2550. 1:37:33editor now connects to this database
  2551. 1:37:36that is running on our computer so
  2552. 1:37:38navigate over to the activity bar and
  2553. 1:37:40select extensions for this you're going
  2554. 1:37:43to go into the search bar and look for
  2555. 1:37:47SQL tools doesn't have any spaces in it
  2556. 1:37:50so that's why it took me a little bit to
  2557. 1:37:51find anyway we're going to go on ahead
  2558. 1:37:53and select this this whenever we click
  2559. 1:37:56install is installing an extension to
  2560. 1:37:58thus supercharge this code editor of vs
  2561. 1:38:02code to allow to connect to SQL so we're
  2562. 1:38:04going to go ahead and click install now
  2563. 1:38:05if you read the front print of this it
  2564. 1:38:07has that to use SQL tools you'll also
  2565. 1:38:09need to install the appropriate driver
  2566. 1:38:12extension for your database a driver is
  2567. 1:38:14now used to connect this extension to a
  2568. 1:38:17database going back to the search bar
  2569. 1:38:19I'm going to type in SQL tools and then
  2570. 1:38:21also postgress SQL
  2571. 1:38:24and pressing control enter we have it
  2572. 1:38:27right here this is called SQL tools
  2573. 1:38:29postgress SQL cockroach driver so this
  2574. 1:38:32installs uh the driver for all these
  2575. 1:38:33different things and click install so I
  2576. 1:38:35can go ahead and close out of this no
  2577. 1:38:37longer need extensions going to explore
  2578. 1:38:39so SQL tools should be installed on here
  2579. 1:38:42right now unfortunately if I zoom out by
  2580. 1:38:44pressing uh command back I can actually
  2581. 1:38:47see it it's located right here it's
  2582. 1:38:49pretty important for me so I'm going to
  2583. 1:38:51just put it right up there anyway I'm
  2584. 1:38:53going to zoom back in and some other
  2585. 1:38:56things are going to hide anyway click on
  2586. 1:38:58SQL tools so it should have add new
  2587. 1:39:00connection so we're going to be adding a
  2588. 1:39:02connection of this postgress this
  2589. 1:39:05initial database in here anytime you
  2590. 1:39:07want to add a new database you have to
  2591. 1:39:09use this or set up this add new
  2592. 1:39:11connection which also can be done bya
  2593. 1:39:12this icon right here so I'm selecting
  2594. 1:39:15add new connection selecting that it's
  2595. 1:39:17postgress this is just the core
  2596. 1:39:19postgress database so I'll use the
  2597. 1:39:21connection name of postgress I'll keep
  2598. 1:39:23all the default settings the way they
  2599. 1:39:24are for database I'll keep it postgress
  2600. 1:39:27for username I'll also name it postgress
  2601. 1:39:30it's going to be really easy for the
  2602. 1:39:32password we're going to be using SQL
  2603. 1:39:33tools the driver that we've installed
  2604. 1:39:35before that way to verify the
  2605. 1:39:37credentials scrolling on down I want to
  2606. 1:39:40say test connection and it says hey this
  2607. 1:39:43extension wants to sign in using the
  2608. 1:39:45driver credentials I will allow it and
  2609. 1:39:47then from here now we need to enter in
  2610. 1:39:49that password from before that we access
  2611. 1:39:52postgress with
  2612. 1:39:54enter again in press enter boom so
  2613. 1:39:56successfully connected I'm going to save
  2614. 1:39:58connection now all right so closing out
  2615. 1:40:01this now this postrest database is not
  2616. 1:40:04the database you can see by this
  2617. 1:40:05database icon right here um is not what
  2618. 1:40:08we're actually going to be using for
  2619. 1:40:09this course this is just a core one
  2620. 1:40:11there I don't really want to mess with
  2621. 1:40:13it let's actually create our own
  2622. 1:40:15database that we're going to be using
  2623. 1:40:17for this course so if we come up here
  2624. 1:40:19selecting on the database itself and
  2625. 1:40:21select new SQL file I can then use this
  2626. 1:40:25to run a query on that database now this
  2627. 1:40:28SQL file is connected to that postest
  2628. 1:40:31database and I know this because if I
  2629. 1:40:33come down here to this bar down here I
  2630. 1:40:36can see that it says postest and this is
  2631. 1:40:38because of the SQL tools if you don't
  2632. 1:40:39have this rightclick it and make sure
  2633. 1:40:41that SQL tools extensions is uh has a
  2634. 1:40:44check mark next to it in order to show
  2635. 1:40:46it so that's the shows what database
  2636. 1:40:48you're connected to that you're about to
  2637. 1:40:50run a query on that if you P this run on
  2638. 1:40:52active connection it's going to do it
  2639. 1:40:54side note real quick you may see during
  2640. 1:40:56this this press command I to ask GitHub
  2641. 1:40:58co-pilot chat to do something start
  2642. 1:40:59typing dismiss just ignore that this is
  2643. 1:41:02my GitHub co-pilot an AI coding
  2644. 1:41:04assistant that I use to actually write
  2645. 1:41:06SQL queries but that's for a whole
  2646. 1:41:08another video just ignore that for the
  2647. 1:41:10time being I may use it from time to
  2648. 1:41:12time if I do I will explain it anyway
  2649. 1:41:14I'm going to enter in this SQL command
  2650. 1:41:17right here of create database SQL course
  2651. 1:41:21and this is going to create a new
  2652. 1:41:23database named SQL course so I can
  2653. 1:41:26select run on active connection or I can
  2654. 1:41:29highlight whatever SQL code I want to
  2655. 1:41:32run right click it and then from there
  2656. 1:41:35go into actually running the selected
  2657. 1:41:38query which is conveniently on Mac the
  2658. 1:41:41shortcut command e command D you have to
  2659. 1:41:43press it twice anyway I'm just going to
  2660. 1:41:45highlight it press command e it's going
  2661. 1:41:47to say hey command e was pressed waiting
  2662. 1:41:49for second key of chord press command e
  2663. 1:41:51again anytime you run a query this SQL
  2664. 1:41:54tools extension is going to have a popup
  2665. 1:41:57on the right hand side if you're running
  2666. 1:41:59a query asking for a table back or some
  2667. 1:42:01results back it's going to display it
  2668. 1:42:03here for us we just created a database
  2669. 1:42:06so we're not going to actually see
  2670. 1:42:08anything anyway I'm going to close this
  2671. 1:42:10out now this new database is created I
  2672. 1:42:15can go back to PG admin I can come up
  2673. 1:42:18here and I can actually see that's
  2674. 1:42:19created by right clicking postgress SQL
  2675. 1:42:2216 and click cing refresh now we have
  2676. 1:42:26two we have postgress and we have that
  2677. 1:42:28SQL courses I need to go ahead and click
  2678. 1:42:31that right now it was gray out and next
  2679. 1:42:33out that means it wasn't running so now
  2680. 1:42:36it is running and we have this we're
  2681. 1:42:37able to connect to it so we're going to
  2682. 1:42:40go ahead now and create a new connection
  2683. 1:42:43once again we want to connect to this
  2684. 1:42:44going to go through the same process I'm
  2685. 1:42:46going to name it SQL course as far as
  2686. 1:42:49the database name itself the name is SQL
  2687. 1:42:52course for the username I'm going to
  2688. 1:42:54keep it the same of postgress then from
  2689. 1:42:57here once again I'm going to test
  2690. 1:42:59connection it's asking it can it use the
  2691. 1:43:02driver connections yes enter in the
  2692. 1:43:04password successfully connected I want
  2693. 1:43:07to save the connection all right so I'm
  2694. 1:43:09going to close out of this I also don't
  2695. 1:43:11need this create database anymore so I'm
  2696. 1:43:12going to close out of this I don't want
  2697. 1:43:14to save it and then now we have this
  2698. 1:43:17when we click it it's available down and
  2699. 1:43:21here's the database itself now notice
  2700. 1:43:23now that I've clicked on it down at the
  2701. 1:43:25bottom I have SQL course selected and I
  2702. 1:43:29could navigate between the two we're
  2703. 1:43:31going to leave it on SQL course for
  2704. 1:43:33basically the remainder of this video
  2705. 1:43:35all right we now have vs code completely
  2706. 1:43:36set up for us I don't really care about
  2707. 1:43:39this test. SQL file anymore I'm going to
  2708. 1:43:41go ahead and delete it you also may see
  2709. 1:43:43this vs code file this is like your
  2710. 1:43:45configuration all this kind of crap in
  2711. 1:43:47there don't worry too much about what's
  2712. 1:43:49in there and how it gets updated just
  2713. 1:43:51keep it there so this concludes the inst
  2714. 1:43:53on vs code we're actually be moving into
  2715. 1:43:55actually understanding more about
  2716. 1:43:57creating deleting and dropping tables
  2717. 1:44:00before that we need to cover some data
  2718. 1:44:03types because it's sort of a
  2719. 1:44:04prerequisite to understand creating
  2720. 1:44:06tables so that see you in the next
  2721. 1:44:12one all right in this short little
  2722. 1:44:14section we're going to cover data types
  2723. 1:44:17and it's really important to understand
  2724. 1:44:19data types because we're about to be
  2725. 1:44:21setting up and creating tables when to
  2726. 1:44:23recreate those tables we have to specify
  2727. 1:44:26the data type for each of the columns
  2728. 1:44:27now if you recall previously whenever we
  2729. 1:44:30were working with our job posting data
  2730. 1:44:32set I didn't call it out specifically
  2731. 1:44:34but the columns were already set up to
  2732. 1:44:36handle a specific data type the job ID
  2733. 1:44:40was only a numeric integer so in this
  2734. 1:44:43case it was specifi as int or integer
  2735. 1:44:46the job title column had strings in it
  2736. 1:44:49and so that was characterized under
  2737. 1:44:51varar job work from home was a false
  2738. 1:44:54zero value or True Value which is one so
  2739. 1:44:57therefore this was a Boolean job posted
  2740. 1:45:00date was timestamp and then salary year
  2741. 1:45:02average could have decimals in it so
  2742. 1:45:04it's not an INT it's going to be numeric
  2743. 1:45:07anyway why is this important well these
  2744. 1:45:10are necessary when setting it up in
  2745. 1:45:12order to have data Integrity within your
  2746. 1:45:15database now if we were to go and add
  2747. 1:45:18data to a database if it did not meet
  2748. 1:45:21the conditions of being an integer to be
  2749. 1:45:24inserted into something like the job ID
  2750. 1:45:27then we wouldn't be able to insert it
  2751. 1:45:29this is really good at just having a
  2752. 1:45:30first line of defense of having clean
  2753. 1:45:33data now additionally because of these
  2754. 1:45:35characterizations of these data types it
  2755. 1:45:38also makes these SQL databases a lot
  2756. 1:45:41more efficient in processing queries it
  2757. 1:45:43doesn't have to guess what the data type
  2758. 1:45:45is inside of a column for integers it
  2759. 1:45:48automatically knows and it can process
  2760. 1:45:49this data a lot more efficiently now if
  2761. 1:45:52I navigate over to the postgress
  2762. 1:45:53documentation they have a whole host of
  2763. 1:45:56data types that you can look at we're
  2764. 1:45:58only going to just focus on a few for us
  2765. 1:46:00and what we'll be working with only
  2766. 1:46:02really think you need to focus on these
  2767. 1:46:04top eight that I use on a common basis
  2768. 1:46:06there's only a couple details I want to
  2769. 1:46:08discuss about this so the first two int
  2770. 1:46:11and numeric int is for an integer
  2771. 1:46:13numeric is for a decimal so in the case
  2772. 1:46:16of this we would specify in parentheses
  2773. 1:46:17Precision which is the number before the
  2774. 1:46:20decimal place and then scale the number
  2775. 1:46:23after the decimal place that we're going
  2776. 1:46:24to have in this next is text and then
  2777. 1:46:27varar I'm just calling it varar I don't
  2778. 1:46:29know what other people call it anyway
  2779. 1:46:31text has an unlimited length for the
  2780. 1:46:34amount of variables that we can put
  2781. 1:46:35within it or the amount of string
  2782. 1:46:36characters we can put in it I don't like
  2783. 1:46:38to have just this type of Freedom so
  2784. 1:46:40we're going to use varar mostly with
  2785. 1:46:42this n variable where inside of it you
  2786. 1:46:45typically specify a value such as
  2787. 1:46:47something like 255 255 characters that
  2788. 1:46:50it's going to allow for the maximum
  2789. 1:46:51length the next is bul and this is going
  2790. 1:46:53to accept either true false or null
  2791. 1:46:56remember our case we had zero or one
  2792. 1:46:59this is effectively true or false and
  2793. 1:47:00then finally those around dates and
  2794. 1:47:02times we have a date one where it's just
  2795. 1:47:04date alone time stamp where it's a date
  2796. 1:47:07and a time and then finally time stamp
  2797. 1:47:10with time zone where we can go ahead and
  2798. 1:47:12specify even further what time zone
  2799. 1:47:15we're in all right so that covers the
  2800. 1:47:16data types and this is important because
  2801. 1:47:19as you can see from the SQL query right
  2802. 1:47:20here whenever we go to create our tables
  2803. 1:47:24we're going to need to go ahead and
  2804. 1:47:26specify the data type that we want to
  2805. 1:47:28make a column this is going to be very
  2806. 1:47:31important like we said for data security
  2807. 1:47:32and with that I'll see you in the next
  2808. 1:47:39one all right let's now get into
  2809. 1:47:41manipulating tables specifically we're
  2810. 1:47:42going to be creating modifying and even
  2811. 1:47:44deleting tables all within that core
  2812. 1:47:47database that we created titled SQL
  2813. 1:47:49courses now there's four main ways we
  2814. 1:47:52can manipulate at a table first one's
  2815. 1:47:54pretty easy just create a table we're
  2816. 1:47:56creating it from stratch next is insert
  2817. 1:47:58into so once we have a table actually
  2818. 1:48:00inserting in Columns of data into it
  2819. 1:48:03next is altering a table we can add
  2820. 1:48:06additional columns even remove them
  2821. 1:48:08change types and then finally just
  2822. 1:48:11deleting a table whatsoever anytime
  2823. 1:48:13you're doing any of these type of
  2824. 1:48:14statements you need to be very careful
  2825. 1:48:17and double check what you're about to do
  2826. 1:48:18twice because once you do it you're not
  2827. 1:48:22able to NE necessarily just click undo
  2828. 1:48:24so picking up from where we left off
  2829. 1:48:25last in the course first inside of PG
  2830. 1:48:28admin make sure that your database is
  2831. 1:48:30still running if it's not you just
  2832. 1:48:32navigate into it and it'll start right
  2833. 1:48:34up and here we have SQL courses the
  2834. 1:48:36other thing to verify is inside of VSS
  2835. 1:48:38code navigate over to SQL tools verify
  2836. 1:48:42that that database is still listed there
  2837. 1:48:44so it is SQL course and also that's
  2838. 1:48:46clicked on so that way it's selected
  2839. 1:48:48down here on the bottom for where we're
  2840. 1:48:50going to be running all these queries or
  2841. 1:48:52about to do all right so I'm going to
  2842. 1:48:54come up here and we're going to create a
  2843. 1:48:55new SQL file in order to run our queries
  2844. 1:48:58on for me I notice this run on active
  2845. 1:49:00connections may disappear or may stay up
  2846. 1:49:02there don't worry about too much about
  2847. 1:49:04that the first statement we're going to
  2848. 1:49:05look at is actually creating a table the
  2849. 1:49:08Syntax for this is relatively simple
  2850. 1:49:10we're going to be using Create table
  2851. 1:49:12along with that table name and then
  2852. 1:49:13enclosed in within parentheses is the
  2853. 1:49:17column names along with that data type
  2854. 1:49:19and you can list as many column names as
  2855. 1:49:21necessary to specify of the table here's
  2856. 1:49:23our situation we're going to create a
  2857. 1:49:25table called job applied and this is a
  2858. 1:49:28table basically that we can track all
  2859. 1:49:29the different jobs we've applied to in
  2860. 1:49:31the past when I've been applying for
  2861. 1:49:33jobs I've made a table similar to this
  2862. 1:49:36usually in an Excel spreadsheet but
  2863. 1:49:37we're going to do this in Excel and this
  2864. 1:49:38includes things like maybe a resume I'm
  2865. 1:49:41using cover letter a contact person at a
  2866. 1:49:43company and then all those different
  2867. 1:49:44companies I'm applying to so we're going
  2868. 1:49:46to create this table called job applied
  2869. 1:49:49and then I'm going to put those in
  2870. 1:49:50closing parentheses around it with a
  2871. 1:49:53semicolon at the end to signify the end
  2872. 1:49:55of the statement from there we're going
  2873. 1:49:56to be putting everything that we need to
  2874. 1:49:58inside of it so anytime you have any
  2875. 1:50:00type of database you usually want some
  2876. 1:50:02sort of ID number so we're going to
  2877. 1:50:03start with the Java ID number specify
  2878. 1:50:05that it's an integer we'll also be
  2879. 1:50:07specifying other portions of the column
  2880. 1:50:09specifically application sent date
  2881. 1:50:12custom resume whether we've modified it
  2882. 1:50:14or not we can include what version it is
  2883. 1:50:16the resume of the file name a cover
  2884. 1:50:18letter whether it's sent or not and then
  2885. 1:50:20the file name of that cover letter and
  2886. 1:50:22then just a status in General on what is
  2887. 1:50:24the job search going on with that
  2888. 1:50:26specific job ID now that we have the SQL
  2889. 1:50:28query generated let's actually navigate
  2890. 1:50:29into SQL tools and then we're going to
  2891. 1:50:32look down this first I want to show if I
  2892. 1:50:34navigate into the SQL courses if I go
  2893. 1:50:36down to this drop down schemas and then
  2894. 1:50:38the tables there's nothing here right
  2895. 1:50:40now so if we create this table it's
  2896. 1:50:42going to go into there now for some
  2897. 1:50:44strange reason this green icon
  2898. 1:50:46indicating the active connection
  2899. 1:50:48switched back to postgress I can also
  2900. 1:50:50see it down here um so I'm going to go
  2901. 1:50:52ahead and just press that right here to
  2902. 1:50:54select
  2903. 1:50:55it and now I can verify it's connected
  2904. 1:50:58by this down here at the bottom also of
  2905. 1:50:59the SQL courses all right so let's run
  2906. 1:51:01this query to create that table we can
  2907. 1:51:03either do this of run on a connections
  2908. 1:51:06selecting that or you can highlight it
  2909. 1:51:09all rightclick it do run select a query
  2910. 1:51:12or finally my favorite just pressing
  2911. 1:51:14command D and then command a and then
  2912. 1:51:17anytime you run a query it's going to
  2913. 1:51:19pop up on the right hand side right here
  2914. 1:51:20promise you you'll have stuff here when
  2915. 1:51:22you actually start querying for data
  2916. 1:51:24back right now we don't so we're just
  2917. 1:51:25going to close this out so right now
  2918. 1:51:27there's still nothing here inside these
  2919. 1:51:29tables what you need to do is come to
  2920. 1:51:31this icon right here and you need to
  2921. 1:51:33refresh them and now magically what
  2922. 1:51:36appeared was the job applied table and I
  2923. 1:51:38can navigate into it and I can see all
  2924. 1:51:41those different values that we created
  2925. 1:51:42right here were the same ones from this
  2926. 1:51:45create table so if I wanted to I could
  2927. 1:51:47just do a select all from java applied
  2928. 1:51:49select it all command e command e run it
  2929. 1:51:53and whenever we get a return back it
  2930. 1:51:54says that there's no data available now
  2931. 1:51:56that we have this empty table we need to
  2932. 1:51:58actually insert into it the data we need
  2933. 1:52:01and we do this with the statement of
  2934. 1:52:03insert into and then from there include
  2935. 1:52:06the table name after this we have a
  2936. 1:52:09parentheses and we enclose all the
  2937. 1:52:11different column names that we want to
  2938. 1:52:13include for inserting the data now if
  2939. 1:52:15we're using every single column name
  2940. 1:52:16inside this table it's not necessary to
  2941. 1:52:19include this it just makes the
  2942. 1:52:20assumption that you're using every
  2943. 1:52:21single one however you have to make sure
  2944. 1:52:24that whenever you get to this values
  2945. 1:52:25portion that where you're going to be
  2946. 1:52:27specifying the different values put in
  2947. 1:52:29that you do have the same order as the
  2948. 1:52:30table or you're going R into issues so
  2949. 1:52:33just for Best Practices I like to
  2950. 1:52:35include both the column names and then
  2951. 1:52:37no matter what whether it's all values
  2952. 1:52:39or not and then the values themselves so
  2953. 1:52:42in vs code I'm going to put in that
  2954. 1:52:44insert into along with that table name I
  2955. 1:52:46want to insert into now I'm going to
  2956. 1:52:47specify all the different column names
  2957. 1:52:49that i' specified previously next I'm
  2958. 1:52:51going to specify value and then start a
  2959. 1:52:53parentheses to put all those different
  2960. 1:52:54values in now here's one entry notice
  2961. 1:52:57it's enclosed inside a parentheses and
  2962. 1:53:00then we have a one with a comma and then
  2963. 1:53:01the next value just's date custom resume
  2964. 1:53:04resume file name cover letter sent and
  2965. 1:53:07cover letter file name and then finally
  2966. 1:53:09status now if I wanted to do more than
  2967. 1:53:11one entry I'm going to just put a comma
  2968. 1:53:13and then insert more in so now in this
  2969. 1:53:15case I have two three four five
  2970. 1:53:18different entries put into this all
  2971. 1:53:20right so let's now actually insert this
  2972. 1:53:21into our table and I'm going to go ahead
  2973. 1:53:24and just select it all and then from
  2974. 1:53:26there command e and then command e again
  2975. 1:53:30and boom get another popup not
  2976. 1:53:32necessarily anything there but let's
  2977. 1:53:34actually verify we inserted into this
  2978. 1:53:36table so I have this select star from
  2979. 1:53:38jaob applied to basically query it all
  2980. 1:53:40make sure I did this pressing command e
  2981. 1:53:43command e it's popping up here I'm
  2982. 1:53:45actually going to move it over so we can
  2983. 1:53:46see it fully on this screen so I have
  2984. 1:53:49the jav ID the application date resume
  2985. 1:53:52resume file name cover letter cover L
  2986. 1:53:55file if we used it or not and then the
  2987. 1:53:58status all right so sweet we now have
  2988. 1:54:00created a table from scratch and
  2989. 1:54:02inserted data into it let's not get into
  2990. 1:54:04altering a table we're going to be doing
  2991. 1:54:05this on this jav appli table the
  2992. 1:54:07statement we're going to use for this is
  2993. 1:54:09Alter table and then the table name then
  2994. 1:54:11depending on what you want to do you're
  2995. 1:54:13going to put one of these four different
  2996. 1:54:15options that we're going to select from
  2997. 1:54:16we can either add a column rename a
  2998. 1:54:18column alter a column or basically
  2999. 1:54:21change its data type and then drop a
  3000. 1:54:23column all right so we're going to start
  3001. 1:54:24off with that keyword of alter table and
  3002. 1:54:26then specify job applied and we're going
  3003. 1:54:29to be creating a table of contact names
  3004. 1:54:33for whatever company we're reaching out
  3005. 1:54:34to so I have add contact and then
  3006. 1:54:37specify that it's going to be a data
  3007. 1:54:39type of far car and allowing only 50
  3008. 1:54:42characters just to verify opening SQL
  3009. 1:54:44tools opening Java applied we can see
  3010. 1:54:45that there's nothing there currently for
  3011. 1:54:47this all right so I almost select it all
  3012. 1:54:50command e command e and whenever we go
  3013. 1:54:54back to it we should see after
  3014. 1:54:56refreshing it now we have this contact
  3015. 1:54:59appear but now you may be like Luke we
  3016. 1:55:01quer that table there's going to be
  3017. 1:55:02nothing in it and you be right so let's
  3018. 1:55:05actually look into it command D command
  3019. 1:55:07D moving it over so we can see it fully
  3020. 1:55:09so we have all this information and then
  3021. 1:55:11for the contact name it's all null now
  3022. 1:55:14this is a bonus command we get to cover
  3023. 1:55:17and that's update update allows us to
  3024. 1:55:20modify existing data within a table for
  3025. 1:55:23this we use the keyword of update
  3026. 1:55:25specifying the name set the column name
  3027. 1:55:28that we want to a certain value where we
  3028. 1:55:31meet a condition and usually this
  3029. 1:55:33condition is you specify a value within
  3030. 1:55:36one of the rows so we'll start with that
  3031. 1:55:38update job applied next we'll do set and
  3032. 1:55:41then we're going to be doing this to
  3033. 1:55:43that contact column name and adding erck
  3034. 1:55:45Bachman and then finally where we're
  3035. 1:55:48going to be just using that index column
  3036. 1:55:49of jaob ID so we want to do this for the
  3037. 1:55:52Java ID of one now we have multiple rows
  3038. 1:55:54to fill in so we're going to do multiple
  3039. 1:55:57statements in this case so I'm going to
  3040. 1:55:59select this all command e and then
  3041. 1:56:01command e again and it's going to go in
  3042. 1:56:03and update it going to close out of this
  3043. 1:56:06and now using that select star from java
  3044. 1:56:08applied running this as
  3045. 1:56:10well I can see that inside of the
  3046. 1:56:13contact it actually inserted all those
  3047. 1:56:15different contact names into it so now
  3048. 1:56:18that we put these names into this column
  3049. 1:56:20called Contact come to the realization
  3050. 1:56:22that this name is not necessarily
  3051. 1:56:24appropriate instead I want to rename it
  3052. 1:56:26from contact to contact name this is
  3053. 1:56:29where the rename column statement comes
  3054. 1:56:31in after specifying alter table we're
  3055. 1:56:33going to go in and specify the original
  3056. 1:56:35column name to the new one so I'll start
  3057. 1:56:37with alter table job applied and then
  3058. 1:56:39rename column contact to contact name
  3059. 1:56:43and then quering this table to actually
  3060. 1:56:45inspect the contents of
  3061. 1:56:47it we can see now that contact was
  3062. 1:56:49changed to contact name now sometimes
  3063. 1:56:52times now that I think of it names can
  3064. 1:56:54be quite long and in this case we set
  3065. 1:56:56that contact name actually Let me
  3066. 1:56:58refresh this right here this contact
  3067. 1:57:00name to 50 characters in length well I
  3068. 1:57:04want to change this data type now from
  3069. 1:57:05varar to text where text doesn't have a
  3070. 1:57:09character limit that needs to be
  3071. 1:57:11specified for it you can put any amount
  3072. 1:57:12of characters into it so I use this
  3073. 1:57:14alter column statement specifying the
  3074. 1:57:15column name and then type to then
  3075. 1:57:17specify the new data type so once again
  3076. 1:57:19start with that alter table and then
  3077. 1:57:21specify the name and then alter column
  3078. 1:57:23column name and finally specifying the
  3079. 1:57:25type as text so running this command
  3080. 1:57:28pressing command D command D we have a
  3081. 1:57:30success message and I find the easiest
  3082. 1:57:32way just to check this data type is come
  3083. 1:57:34back into here and we'll refresh this
  3084. 1:57:36and now we see that it is text now I do
  3085. 1:57:39want to call out there are certain
  3086. 1:57:41limitations in changing this data so in
  3087. 1:57:44this contact name example it has string
  3088. 1:57:47characters in it if I wanted to actually
  3089. 1:57:49change this data type to int and then
  3090. 1:57:51try and to actually execute it by
  3091. 1:57:53pressing command e command e I'm going
  3092. 1:57:55to get this column contact name cannot
  3093. 1:57:58be cast automatically to type integer
  3094. 1:58:00because it has a string in there it's
  3095. 1:58:01not going to be able to make any of
  3096. 1:58:02those that are letters into an integer
  3097. 1:58:04so it's not going to be able to do this
  3098. 1:58:06so really it's important that you get
  3099. 1:58:07this correct on the first time whenever
  3100. 1:58:09building your table for the first time
  3101. 1:58:11and now let's say this column of contact
  3102. 1:58:13names we decided we're not going to go
  3103. 1:58:15ahead forward with it because instead
  3104. 1:58:17we're going to be using LinkedIn profile
  3105. 1:58:19information to gather this information
  3106. 1:58:21and we're going to be creating separate
  3107. 1:58:22table for this so we don't need this
  3108. 1:58:24contact name column anymore in this case
  3109. 1:58:26we can use drop column which is the
  3110. 1:58:28simplest and also probably the most
  3111. 1:58:30dangerous in that you just specify the
  3112. 1:58:31column name and remove it so opening up
  3113. 1:58:34SQL tools I can see that refreshing it
  3114. 1:58:36that we have that contact name right now
  3115. 1:58:38is a text so entering in that keyword of
  3116. 1:58:40drop column and then specifying that
  3117. 1:58:42contact name I can then see how we can
  3118. 1:58:45remove it by running this query command
  3119. 1:58:47e command e okay refreshing this we can
  3120. 1:58:50see that contact name no more and it's
  3121. 1:58:53gone all right last command of dropping
  3122. 1:58:55the tables let's say that we're now
  3123. 1:58:56tired of having to go into SQL and
  3124. 1:58:58insert our records using all these
  3125. 1:59:00different commands we're going to just
  3126. 1:59:01use a spreadsheet software instead which
  3127. 1:59:03I probably should use anyway anyway we
  3128. 1:59:04can go in now and specify drop table and
  3129. 1:59:07then specifying the name itself be
  3130. 1:59:10extremely careful anytime you're doing
  3131. 1:59:12these drop columns or drop tables as
  3132. 1:59:15this is very much permanent so
  3133. 1:59:17specifying drop table and then job
  3134. 1:59:20applied let's go ahead and Drop It Like
  3135. 1:59:23It's Hot bam we ran this refreshing this
  3136. 1:59:26query right now where job is applied is
  3137. 1:59:28right here it's still there got to wait
  3138. 1:59:30a second okay it took about a minute for
  3139. 1:59:33me on my computer but refreshing this
  3140. 1:59:35now we can see that nothing is here
  3141. 1:59:37sometimes especially if you're going to
  3142. 1:59:38be doing large changes to databases or
  3143. 1:59:41dropping them or removing them there's a
  3144. 1:59:43lot of code that goes on in the
  3145. 1:59:44background besides these three simple
  3146. 1:59:47keywords right here that we're able to
  3147. 1:59:48do this with so you got to wait a little
  3148. 1:59:50bit of time all right now it's your turn
  3149. 1:59:51get give it a try feel free to walk
  3150. 1:59:53through this example that I just took
  3151. 1:59:55you through making up any relative
  3152. 1:59:56values that you would rather use instead
  3153. 1:59:59all right with that see you in the next
  3154. 2:00:01one all right let's now get into loading
  3155. 2:00:04the database that we're going to be
  3156. 2:00:05using for this continuation of the
  3157. 2:00:08advanced section and we'll be also be
  3158. 2:00:09using it as well in the portfolio
  3159. 2:00:12project section this data is going to be
  3160. 2:00:15of the same schema using the same tables
  3161. 2:00:17and column names that we were using
  3162. 2:00:19previously in SQL light F however this
  3163. 2:00:22data set is a lot more robust and
  3164. 2:00:24includes a lot more details from 2023
  3165. 2:00:28and for those that are maybe a little
  3166. 2:00:29lazy and want to continue just stay
  3167. 2:00:31inside of sqlite viz and enter queries
  3168. 2:00:34from time to time you can continue to do
  3169. 2:00:36so but I can't guarantee you that any of
  3170. 2:00:38the queries that we go forward with will
  3171. 2:00:40work inside of here I highly recommend
  3172. 2:00:42you just follow along what we're doing
  3173. 2:00:44so how are we're going to do this all
  3174. 2:00:45well three simple steps first we're
  3175. 2:00:47going to download all the data which is
  3176. 2:00:50in CSV files and also SQL files from
  3177. 2:00:53there we're going to move into VSS code
  3178. 2:00:54and create the tables using some SQL
  3179. 2:00:57files that I'm going to give you and
  3180. 2:00:59finally now that we have all these empty
  3181. 2:01:00tables we need to load the data all into
  3182. 2:01:03it that'll be our final step so let's
  3183. 2:01:04jump into it so if you navigate to the
  3184. 2:01:06URL in the screen right here you're
  3185. 2:01:08going to be directed to this Google
  3186. 2:01:10Drive where it has a couple of contents
  3187. 2:01:12inside of it first is a folder with all
  3188. 2:01:14the different CSV files in it and these
  3189. 2:01:17are conveniently named after the four
  3190. 2:01:19different tables we're going to be
  3191. 2:01:20creating inside of our database and you
  3192. 2:01:23can even peek inside of there and see
  3193. 2:01:25where the contents are overall it's just
  3194. 2:01:27Comm of separate variables inside of it
  3195. 2:01:29all right so back in the main folder the
  3196. 2:01:31other main file in there is the SQL load
  3197. 2:01:34folder and it has the SQL files that
  3198. 2:01:36we're going to be using to not only
  3199. 2:01:38create our tables but also modify our
  3200. 2:01:40tables pecking into it we can see that
  3201. 2:01:42this create tables one it's pretty long
  3202. 2:01:45so now we're going to just download
  3203. 2:01:46these now you can download these folders
  3204. 2:01:49individually or I actually just zip them
  3205. 2:01:52into their own little zip file to make
  3206. 2:01:55this quicker for you to download so you
  3207. 2:01:57can do either or the one issue with the
  3208. 2:01:59zip file is you can't scan it for
  3209. 2:02:01viruses so if you're not comfortable
  3210. 2:02:03with it just download the other two
  3211. 2:02:04files exact same thing all right so
  3212. 2:02:06navigate back inside of a VSS code we're
  3213. 2:02:08going to be now adding those folders
  3214. 2:02:09navigate into that project folder that
  3215. 2:02:11you created from previously you may have
  3216. 2:02:13it open if not open a new window and it
  3217. 2:02:15should pop under recent and you can just
  3218. 2:02:17select it there now I'm going to go
  3219. 2:02:19ahead and uh select the two files that
  3220. 2:02:21we've downloaded I unzipped them and
  3221. 2:02:23then I have them right here I'm going to
  3222. 2:02:24take them and I'm going to actually just
  3223. 2:02:25drop them right inside of here it says
  3224. 2:02:28do you want to copy the folders or add
  3225. 2:02:30the folders to your workspace I'm just
  3226. 2:02:32going to select copy folders over and
  3227. 2:02:34it's going to place them right in I did
  3228. 2:02:35add folders workspace previously and it
  3229. 2:02:37did something funky I want it inside my
  3230. 2:02:40project itself so that's why I did the
  3231. 2:02:41copy over now since we added a copy just
  3232. 2:02:43going to do some cleanup you don't need
  3233. 2:02:45this ZIP file or this original folder
  3234. 2:02:48that I have right here I'm just going to
  3235. 2:02:49select it and delete it and remove it
  3236. 2:02:51from my uh remove it all right so the
  3237. 2:02:53first step is done now let's actually
  3238. 2:02:55get into creating these tables for the
  3239. 2:02:57database so back of vs code I'm going to
  3240. 2:02:59navigate into this SQL load folder and I
  3241. 2:03:03have this one here already on create
  3242. 2:03:05database if you haven't done this
  3243. 2:03:07already you can go ahead and execute
  3244. 2:03:08this in order to run and ex and create
  3245. 2:03:11this database that we're going to need
  3246. 2:03:12for this but let me just verify real
  3247. 2:03:14quick that we have this set up so I'm
  3248. 2:03:16going to click on SQL course I logged
  3249. 2:03:18out recently so it just asked me to
  3250. 2:03:20verify my credentials and enter in the
  3251. 2:03:22password and then I see I have the SQL
  3252. 2:03:24course database already so I don't need
  3253. 2:03:26to do this create database now as a
  3254. 2:03:28reminder again make sure that we
  3255. 2:03:29maintain this SQL course connection
  3256. 2:03:32established for this is where we're
  3257. 2:03:33wanting to create all these tables I'm
  3258. 2:03:35going go ahead and close out of these so
  3259. 2:03:38navigating back into the explore back
  3260. 2:03:40into the create tables in this one is
  3261. 2:03:44four different SQL queries for creating
  3262. 2:03:46tables we have one for creating the
  3263. 2:03:48company dim one for creating the skills
  3264. 2:03:50dim one for job postings fact and then
  3265. 2:03:53the fourth one for skills job dim these
  3266. 2:03:57four commands are nothing different than
  3267. 2:03:59what we learned in the last section for
  3268. 2:04:01creating table the only difference now
  3269. 2:04:03is we added a keyword in here for
  3270. 2:04:06specifying when we're using a primary
  3271. 2:04:08key and then when we're using uh
  3272. 2:04:11something like a foreign key so in this
  3273. 2:04:13case right here as a quick refresher on
  3274. 2:04:16primary and foreign keys so if we go
  3275. 2:04:18back to that core database schema that
  3276. 2:04:20we have job post postings fact so we
  3277. 2:04:23have this job ID in there and that's
  3278. 2:04:25unique to this column or this data set
  3279. 2:04:28right here that is the primary key in
  3280. 2:04:30job postings fact however in something
  3281. 2:04:33like skills job dim the job ID is now
  3282. 2:04:36the foreign key conversely skills dim is
  3283. 2:04:39the main table when it comes to skills
  3284. 2:04:42so that skill ID is unique value in
  3285. 2:04:44there so that's the primary key in this
  3286. 2:04:46one and in skills job dim it's the
  3287. 2:04:49foreign key so back inside of our SQL
  3288. 2:04:51file we can see that the job ID itself
  3289. 2:04:54is that primary key in the job postings
  3290. 2:04:57fact table and then in that skills job
  3291. 2:05:00dim table it is a foreign key then we
  3292. 2:05:03also have to specify references
  3293. 2:05:06specifying what table is the primary key
  3294. 2:05:08in along with that value we expected to
  3295. 2:05:11be for that primary key conversely that
  3296. 2:05:13skills dim table has that skill ID as
  3297. 2:05:16the primary key and then the skills job
  3298. 2:05:18dim has that skill ID Associated as a
  3299. 2:05:21boring key and we also have that company
  3300. 2:05:23dim table which has that primary key and
  3301. 2:05:26then Associates it into that job posting
  3302. 2:05:28fact table as a foreign key right
  3303. 2:05:31there's two major last statements I want
  3304. 2:05:32to go over first is the owner we go
  3305. 2:05:35through and actually establish the owner
  3306. 2:05:37as postgress for this because we've
  3307. 2:05:40already set up our connections already
  3308. 2:05:41within vs code using postgress we want
  3309. 2:05:43to make sure it uses this and then
  3310. 2:05:45finally in order to speed up performance
  3311. 2:05:47we have this create index and we're not
  3312. 2:05:50going to be using this at all don't
  3313. 2:05:52worry about it it just speeds up the
  3314. 2:05:53queries a little bit more and it
  3315. 2:05:55basically specifies the different
  3316. 2:05:57foreign keys and helps with actually
  3317. 2:06:00aggregating or creating as an index to
  3318. 2:06:01speed up the query performance so now
  3319. 2:06:03that everybody's all comfortable and
  3320. 2:06:05knows each other let's actually get into
  3321. 2:06:06executing this query I'm going to go
  3322. 2:06:08ahead and select it all and then from
  3323. 2:06:11there verify that SQL courses is in fact
  3324. 2:06:14the connection that I'm connected to and
  3325. 2:06:16then from there press command D command
  3326. 2:06:19D now this is going to take some time
  3327. 2:06:20like previously in order for these
  3328. 2:06:22tables to show up navigating over to SQL
  3329. 2:06:25courses schemas public and then tables
  3330. 2:06:27oh actually looks like they popped in
  3331. 2:06:30already and just do an inspection
  3332. 2:06:32everything everything's looking good
  3333. 2:06:34conveniently we can also see based on
  3334. 2:06:37this that like job ID has that primary
  3335. 2:06:40key which is has this gold icon for a
  3336. 2:06:42key and then Company ID has this foreign
  3337. 2:06:45key of this silver one all right we're
  3338. 2:06:47almost done we've now downloaded all the
  3339. 2:06:49files created tables now we need to load
  3340. 2:06:51this down add it in to the tables that
  3341. 2:06:53we just created so navigate back into
  3342. 2:06:55our files looking at the explore menu
  3343. 2:06:57we're going to go into this one now of
  3344. 2:06:59three of modifying tables this is going
  3345. 2:07:02to be a new SQL command that we haven't
  3346. 2:07:05seen before and it consists of three
  3347. 2:07:07things in order to copy the contents
  3348. 2:07:10into a certain table based on a certain
  3349. 2:07:12file so this starts first with the
  3350. 2:07:14keyword copy and then we're specifying
  3351. 2:07:16the table we want to copy data into next
  3352. 2:07:20is from we're going to then specify the
  3353. 2:07:23file path location which you're going to
  3354. 2:07:25have to update all these for your file
  3355. 2:07:27path location and I will too actually
  3356. 2:07:29and this is going to specify where the
  3357. 2:07:31CSV is living and then finally we need
  3358. 2:07:34to specify that we're copying into here
  3359. 2:07:37this CSV file and I'm going to specify
  3360. 2:07:40this with delimiter and then specifying
  3361. 2:07:42what it's using to separate all the
  3362. 2:07:44different variables in there which is a
  3363. 2:07:46comma and then the keyword CSV header
  3364. 2:07:49header is going to specify there is a
  3365. 2:07:51header or basically column names at the
  3366. 2:07:53top row of this data set okay so we need
  3367. 2:07:56to update the file location for all four
  3368. 2:07:59of these so I'm going to navigate back
  3369. 2:08:01into the explore into the CSV files
  3370. 2:08:05themsel we're going to start with that
  3371. 2:08:06company DM what you can do is you can
  3372. 2:08:08rightclick this and then select copy
  3373. 2:08:12path now inside of these parentheses
  3374. 2:08:15here I'm going to go ahead and just
  3375. 2:08:18paste this into here and then I'm going
  3376. 2:08:20to do this for all the remaining being
  3377. 2:08:23very careful that we're using whatever
  3378. 2:08:25the name of the CSV file is for the file
  3379. 2:08:28path
  3380. 2:08:33itself all right so I've gone through
  3381. 2:08:36and actually updated them all to make
  3382. 2:08:38sure that they match I'm going to go
  3383. 2:08:39ahead and actually save it by pressing
  3384. 2:08:41command s all right so now it's ready
  3385. 2:08:43last chance to verify that you have all
  3386. 2:08:45those correct CSV files underneath the
  3387. 2:08:48correct table names select it all
  3388. 2:08:51command e command
  3389. 2:08:54D and this is going to take a little bit
  3390. 2:08:56of time to load all this data into it
  3391. 2:09:00all right so that was about a minute for
  3392. 2:09:02me for this to all load I'm going to go
  3393. 2:09:04ahead once again anytime I do any of
  3394. 2:09:06these there's nothing really appearing
  3395. 2:09:07here so I want to verify that I got this
  3396. 2:09:09data into it I inserted it in correctly
  3397. 2:09:11I'm going to just create this simple
  3398. 2:09:13statement real quick of selecting all
  3399. 2:09:15columns from job posting fact a lot of
  3400. 2:09:18data in there I don't want to query
  3401. 2:09:19everything just yet so so I'm just going
  3402. 2:09:21to limit this to 100 values selecting it
  3403. 2:09:24all pressing command D command D moving
  3404. 2:09:27this window over here it looks like all
  3405. 2:09:30of the data loaded into it so now we're
  3406. 2:09:33cooking feel free to also go through and
  3407. 2:09:36check any other tables as well verifying
  3408. 2:09:38that they all loaded but based on this
  3409. 2:09:40other one I'm pretty confident that all
  3410. 2:09:42the other ones are loaded just fine as
  3411. 2:09:45well all right we did it just created
  3412. 2:09:47our entire database from scratch using
  3413. 2:09:50CSV files but then loaded in using some
  3414. 2:09:52SQL queries and it's all lited up all
  3415. 2:09:54right next we're going to be jumping
  3416. 2:09:55into some date functions and uh some
  3417. 2:09:58more advanced features so with that see
  3418. 2:10:00you in the next
  3419. 2:10:05one all right in this section we're
  3420. 2:10:07going to be going over dates and also
  3421. 2:10:09times this is a very critical component
  3422. 2:10:12as an analyst be able to understand how
  3423. 2:10:14to manipulate dates and times because on
  3424. 2:10:16depending where in the world you're
  3425. 2:10:18working on data from you may have to
  3426. 2:10:20convert it now for for this section
  3427. 2:10:21we're going to be working inside that
  3428. 2:10:23table job postings fact and specifically
  3429. 2:10:26we're going to be working with a column
  3430. 2:10:28of job posted date this not only has a
  3431. 2:10:31date but it also has a Time associated
  3432. 2:10:33with it so it's a timestamp value and
  3433. 2:10:36this value in each one of these rows it
  3434. 2:10:39correlates to the date and time that a
  3435. 2:10:41job was posted so for this we're going
  3436. 2:10:43to be focusing on three main keywords or
  3437. 2:10:45operators in order to handle dates the
  3438. 2:10:48first is how to cast timestamps as a
  3439. 2:10:50date next is how can we work with time
  3440. 2:10:53zones and convert to different time
  3441. 2:10:54zones and then finally we're going to
  3442. 2:10:56work with my favorite extract being able
  3443. 2:10:58to pull out things like year month out
  3444. 2:11:00of a date all right the first thing
  3445. 2:11:02we're going to look at is how to cast
  3446. 2:11:04different values or types to a different
  3447. 2:11:06data type so in the case of our posted
  3448. 2:11:10date this is a timestamp and we want to
  3449. 2:11:14if we wanted to cast it as a date we
  3450. 2:11:17would use this double colon which allows
  3451. 2:11:19us to specify the data type we want to
  3452. 2:11:22cast something to this is typically used
  3453. 2:11:25within the select statement in order to
  3454. 2:11:27assign it to maybe a column name and we
  3455. 2:11:30haven't seen this before which you can
  3456. 2:11:31actually run queries without actually
  3457. 2:11:33using a from statement to select a
  3458. 2:11:35database so in this case I can say just
  3459. 2:11:36select a string value in this case I'm
  3460. 2:11:39selecting the string value of a date and
  3461. 2:11:41I'm going to press command e command e
  3462. 2:11:43to run it so right now it provided this
  3463. 2:11:46query of basically the string inside of
  3464. 2:11:48it but instead I can actually cast it by
  3465. 2:11:51using this double colon and then from
  3466. 2:11:54there specifying the data type date from
  3467. 2:11:57here I'm going to just go ahead and
  3468. 2:11:59command e command e and run it and now
  3469. 2:12:02it has this as a date now to show this
  3470. 2:12:05for values we can actually see inside of
  3471. 2:12:08here that we've actually converted to a
  3472. 2:12:09different data type I did some other
  3473. 2:12:11examples converting this one two three
  3474. 2:12:13string to an integer true as a string to
  3475. 2:12:16booing and then 3.14 string to real in
  3476. 2:12:20this case we can actually see the
  3477. 2:12:21conversion the iner it has this gray box
  3478. 2:12:23around it Boolean it actually has the
  3479. 2:12:26green around it to signify that it's a
  3480. 2:12:28true value and then same with the float
  3481. 2:12:30the gray around it so let's actually see
  3482. 2:12:32this in action we're going to get back
  3483. 2:12:33into actually running queries on our
  3484. 2:12:35database and remember be sure that you
  3485. 2:12:37have it set up through SQL tools that
  3486. 2:12:39you're connected to that SQL course that
  3487. 2:12:41it's actually active and you have SQL
  3488. 2:12:43courses as the connection down here at
  3489. 2:12:45the bottom so I'm going to go ahead and
  3490. 2:12:46run this query and for it we can see
  3491. 2:12:50that we have the title the location and
  3492. 2:12:52then the date and with this date we also
  3493. 2:12:54have this time stamp associated with it
  3494. 2:12:57because it is in fact a time stamp value
  3495. 2:12:59let's say we only needed that date value
  3496. 2:13:03from this column and we don't really
  3497. 2:13:05care about that time stamp well I can
  3498. 2:13:07convert this data type of timestamp to
  3499. 2:13:11date and we do this by specifying that
  3500. 2:13:13double call-in and then the data type of
  3501. 2:13:15date running this all together pressing
  3502. 2:13:18command D command D we can now see that
  3503. 2:13:20we have the title location and then date
  3504. 2:13:22it automatically cleaned it up for us
  3505. 2:13:24and removed that time all right next up
  3506. 2:13:27is at time zone a keyword in order to
  3507. 2:13:30convert timestamps to as you guessed it
  3508. 2:13:33different time zones now it can be used
  3509. 2:13:35with timestamp data whether it has a
  3510. 2:13:38time zone specified or not as we refresh
  3511. 2:13:41it from our data type section timestamp
  3512. 2:13:43alone includes things like the date and
  3513. 2:13:45time whereas time stamp with time zone
  3514. 2:13:48includes all that and then includes
  3515. 2:13:50either a plus or minus to adjust the
  3516. 2:13:53time zone based on where it is now if we
  3517. 2:13:56go back in to see the data that we
  3518. 2:13:58imported by specifically going to that
  3519. 2:14:00job posting fact table CSV that was
  3520. 2:14:02imported into our table and then scroll
  3521. 2:14:05over to see the job posted date column I
  3522. 2:14:09have this convenient coloring scheme so
  3523. 2:14:11you can actually see it but anyway
  3524. 2:14:13here's one of the dates right here right
  3525. 2:14:14it's just a uh where the time stamps
  3526. 2:14:17it's a date and then a time there is no
  3527. 2:14:20time stamp on the end into this so the
  3528. 2:14:22data in our database does not include
  3529. 2:14:24time zone information so here I have
  3530. 2:14:26that similar query from before where
  3531. 2:14:28we're looking at title location but also
  3532. 2:14:30that date time we're going to go ahead
  3533. 2:14:32and actually investigate what the column
  3534. 2:14:33looks like and similar to before that
  3535. 2:14:36date time includes things like date time
  3536. 2:14:38and we want to pay attention to these
  3537. 2:14:41top values right here these aren't going
  3538. 2:14:43to change from query to query on the top
  3539. 2:14:4610 values actually I'll just leave it to
  3540. 2:14:48five we're going to leave these up here
  3541. 2:14:50and actually pay particular attention to
  3542. 2:14:52these as we go through this example to
  3543. 2:14:54understand this more and still the same
  3544. 2:14:56ones up here but remember that 1746 now
  3545. 2:14:59if our data came as a time stamp with
  3546. 2:15:01time zone whenever we use this at time
  3547. 2:15:04zone keyword we'd only have to specify
  3548. 2:15:07at once so you'd specify the column name
  3549. 2:15:09add time zone and then from there
  3550. 2:15:11specify the time zone you want to go to
  3551. 2:15:13in this case we're showing Eastern
  3552. 2:15:15Standard time now in our situation is
  3553. 2:15:18different so it makes it a little bit
  3554. 2:15:19more complicated because we don't have
  3555. 2:15:21time zone information we need to First
  3556. 2:15:24specify the time zone that this value
  3557. 2:15:26actually is by saying at time zone and
  3558. 2:15:29then from there use at time zone again
  3559. 2:15:32to specify the time zone we want to go
  3560. 2:15:34to in this example we're showing from
  3561. 2:15:36UTC converting it to Eastern Standard
  3562. 2:15:39Time so going back to that previous
  3563. 2:15:41query that date time these values here I
  3564. 2:15:44know from actually collecting the data
  3565. 2:15:47this value is UTC so I'm going to first
  3566. 2:15:51start by specifying at time zone and
  3567. 2:15:54then specifying UTC and then we're going
  3568. 2:15:56to do it again to go to the time we want
  3569. 2:15:59to go to let's go to Eastern Standard
  3570. 2:16:01Time so now I have at time zone EST we
  3571. 2:16:05can see it fully here now Eastern
  3572. 2:16:08Standard Time is 5 hours prior to UTC so
  3573. 2:16:12whenever I run this I should expect it
  3574. 2:16:14to adjust this appropriately and Bam we
  3575. 2:16:17went from that 1746 to 1246 so 5 hours
  3576. 2:16:22prior now if you Google the postrest
  3577. 2:16:24documentation on different time zones
  3578. 2:16:27you can see that they have a whole host
  3579. 2:16:29of time zone basically every single time
  3580. 2:16:31zone available for you to use here in
  3581. 2:16:34our case we were converting that UTC
  3582. 2:16:36which is at 0 to that Eastern Standard
  3583. 2:16:40Time which is that -5 the last keyboard
  3584. 2:16:43we're going to be looking at is extract
  3585. 2:16:45and this is used to extract things out
  3586. 2:16:48of the date such as the year month or
  3587. 2:16:50even day this is used like a function
  3588. 2:16:53within the select statement so I would
  3589. 2:16:55do something like select and from there
  3590. 2:16:57specify extract function and then inside
  3591. 2:17:00of the parentheses specify what I want
  3592. 2:17:03to get from the column of interest in
  3593. 2:17:06this case I want to get the month from
  3594. 2:17:08the column name and then I'm just
  3595. 2:17:10renaming it as column month so going
  3596. 2:17:12back to that previous query we have the
  3597. 2:17:13title location and then also date time
  3598. 2:17:15let say we want to extract the month out
  3599. 2:17:18of that job posting date I would first
  3600. 2:17:20start with that extract function from
  3601. 2:17:22there i' would specify what the value I
  3602. 2:17:24want from it is then specify the keyword
  3603. 2:17:28from and then finally the actual column
  3604. 2:17:31of interest and then we'll name this one
  3605. 2:17:34date month selecting it all and then
  3606. 2:17:37running it we can see we have from this
  3607. 2:17:40the month values from that date time so
  3608. 2:17:43977 43 I could even take it a step
  3609. 2:17:46further and add something like the year
  3610. 2:17:48to this and from here command e command
  3611. 2:17:51D we can see from this we got the year
  3612. 2:17:53into this column now you may be like
  3613. 2:17:55Luke what is this actually useful for
  3614. 2:17:57well when we actually use this something
  3615. 2:18:00like this in combination with something
  3616. 2:18:02like the group by function I could do
  3617. 2:18:05larger Trend analysis with SQL
  3618. 2:18:08specifically let's say we want to look
  3619. 2:18:10at how job postings are trending from
  3620. 2:18:13month to month so let's start with a
  3621. 2:18:15simple query and build on it further I
  3622. 2:18:17want to first start by just getting
  3623. 2:18:19things like the job ID and then the
  3624. 2:18:21month from each of the job posted date
  3625. 2:18:24columns running this query to double
  3626. 2:18:26check that it's working I can see that
  3627. 2:18:28I'm getting it right here now I want to
  3628. 2:18:31aggregate it so I want to do a count of
  3629. 2:18:34these different job IDs for each month
  3630. 2:18:39so I'll start by putting a count around
  3631. 2:18:42job ID and then from there add a group
  3632. 2:18:45bu to then specify we're going to group
  3633. 2:18:48bu this new month column running this
  3634. 2:18:51all command D command D we're getting
  3635. 2:18:53these first five values now we're down
  3636. 2:18:55to 12 so I'm just going to go remove
  3637. 2:18:57ahead this uh limit column and then run
  3638. 2:18:59this again to actually see all of them
  3639. 2:19:01so bam it's shown us all the different
  3640. 2:19:03months and then all the different values
  3641. 2:19:05now personally I only really care about
  3642. 2:19:06data analyst roles so I'm just going to
  3643. 2:19:08take it even a step further and then use
  3644. 2:19:10a wear
  3645. 2:19:13Clause specifying the job title short of
  3646. 2:19:16data analyst and then just for a little
  3647. 2:19:18cherry on top we're going to do an order
  3648. 2:19:21bu and then in this case we want to
  3649. 2:19:23obviously do the count so just not to be
  3650. 2:19:26repetitive I'm going to rename this job
  3651. 2:19:29posted count and then specify this down
  3652. 2:19:32here of job posted count okay running
  3653. 2:19:36this all command e command D we can see
  3654. 2:19:39that this is ordered from low to high
  3655. 2:19:41and I obviously don't like that so we're
  3656. 2:19:43going to just change this to descending
  3657. 2:19:45and then rerun this query again command
  3658. 2:19:47e command D and then from this we can
  3659. 2:19:49see that there looks like there's a
  3660. 2:19:52trend that earlier in the year so
  3661. 2:19:54January feary March have higher job
  3662. 2:19:56posting counts specifically with January
  3663. 2:19:58having some of the highest and then
  3664. 2:20:00later in the year like December November
  3665. 2:20:03and September are lower on the list and
  3666. 2:20:06this pretty much tracks with what I
  3667. 2:20:08would expect all right now it's your
  3668. 2:20:09turn to give it a try I have a few
  3669. 2:20:11practice problems aligned with not only
  3670. 2:20:14using the different datetime functions
  3671. 2:20:15that we just went over but also
  3672. 2:20:17aggregating it with some previous
  3673. 2:20:19functions that we used in order to look
  3674. 2:20:21at things like salary and counts of jobs
  3675. 2:20:24all right with that see you in the next
  3676. 2:20:30one all right in this section we're
  3677. 2:20:32going to get into a practice problem
  3678. 2:20:34using what we just learned on the dates
  3679. 2:20:36and also we learned previously on create
  3680. 2:20:39tables specifically we want to create
  3681. 2:20:42tables for each month of these job
  3682. 2:20:46postings so I want all of the data for
  3683. 2:20:48say January in its own individual table
  3684. 2:20:52a little bit of foreshadowing here we're
  3685. 2:20:53going to be using all these different
  3686. 2:20:56months in upcoming practice problems
  3687. 2:20:58when we go over even more advanced
  3688. 2:21:01operations so anytime I'm doing
  3689. 2:21:02something like this I want to just start
  3690. 2:21:04the very Basics so let's start very
  3691. 2:21:06basic first with the query to actually
  3692. 2:21:08connect to the database so we'll start
  3693. 2:21:10with this of Select star from job
  3694. 2:21:12posting fact and then I want to speed up
  3695. 2:21:15these queries for the time being so I'm
  3696. 2:21:16going to just put a limit statement on
  3697. 2:21:17the time being to speed it up all right
  3698. 2:21:21so we have all our information so the
  3699. 2:21:22next thing we want to focus on is this
  3700. 2:21:24job posted date remember we want to make
  3701. 2:21:27tables for every single month or at
  3702. 2:21:30least the first three months January
  3703. 2:21:31febrary March so let's start by
  3704. 2:21:34filtering this job posted date column
  3705. 2:21:37and only get values that have January in
  3706. 2:21:40it so in this case I can use that wear
  3707. 2:21:43statement and then we're going to
  3708. 2:21:45specify extract and we're going to use
  3709. 2:21:47the function we want to remember we want
  3710. 2:21:49to specify that we're gonna be using
  3711. 2:21:50month from this job posted date now we
  3712. 2:21:55need to specify what this condition
  3713. 2:21:57actually meets of extract month from job
  3714. 2:22:00date in our case when it equals one so
  3715. 2:22:03I'm going go ahead and select this all
  3716. 2:22:05here and press command e command e again
  3717. 2:22:09and scrolling over to that job posted
  3718. 2:22:12date column I can now see that we have
  3719. 2:22:15nothing but January dates in this column
  3720. 2:22:18okay we go ahead and close this x I
  3721. 2:22:20don't need need this anymore now we're
  3722. 2:22:21trying to create a table for this job
  3723. 2:22:24post to date of only January and
  3724. 2:22:28remember if we go back to our SQL tools
  3725. 2:22:30extension on the left hand side and
  3726. 2:22:32actually go into our tables folder we
  3727. 2:22:35can see we have these four folders right
  3728. 2:22:36now so we want to create a table an
  3729. 2:22:38additional one inside of here so first
  3730. 2:22:40I'm going to remove this limit statement
  3731. 2:22:42and once again make sure that it runs
  3732. 2:22:45it's going to take a little bit longer
  3733. 2:22:46to run and Bam we looks like we have
  3734. 2:22:49around 92 th000 values the next thing I
  3735. 2:22:52want to do is now use a statement of
  3736. 2:22:57create table we're going to specify the
  3737. 2:23:00name of this table so in their case
  3738. 2:23:02January jobs and then we'll use the as
  3739. 2:23:06alas to assign this and just to format
  3740. 2:23:09this better to make it look more
  3741. 2:23:11appropriate I'm going tab this over bam
  3742. 2:23:13so that's how we'd want to do this and
  3743. 2:23:15I'll put a little uh semicolon at the
  3744. 2:23:17end of this so we have this for January
  3745. 2:23:19we also need this for February and March
  3746. 2:23:22I'm going to show you a little trick
  3747. 2:23:23that I do this so I'm going to copy all
  3748. 2:23:25this by pressing command C and then if
  3749. 2:23:27you go into any AI assistant in this
  3750. 2:23:29case we're using chat GPT specifically
  3751. 2:23:31the chatbot for this course I can then
  3752. 2:23:33specify in there to make this for other
  3753. 2:23:35months so I specify make this query for
  3754. 2:23:38all months in the year and then from
  3755. 2:23:40there paste in that SQL query let's see
  3756. 2:23:43what it does boom okay so in this case
  3757. 2:23:46Chad gbt went through and did this all
  3758. 2:23:49anytime you find very rep competive work
  3759. 2:23:50you need to jump into chat chv to do
  3760. 2:23:52this now remember we only need these
  3761. 2:23:54three months right here and I have gone
  3762. 2:23:56through and verified that it does in
  3763. 2:23:58fact use the right syntax chat BT coming
  3764. 2:24:00wrong sometimes so make sure you're
  3765. 2:24:01always double checking it anyway I'm
  3766. 2:24:03going to copy it by pressing command C
  3767. 2:24:05and then going back in here and pressing
  3768. 2:24:07command V I also went in and added some
  3769. 2:24:09indentation all right let's create all
  3770. 2:24:11these different Tables by pressing
  3771. 2:24:13command e command e okay so it looks
  3772. 2:24:16like once again we got this blank screen
  3773. 2:24:17that the tables were made I can come
  3774. 2:24:20over here and I'm I'm going to press
  3775. 2:24:22refresh inside of SQL tools and Bam
  3776. 2:24:25there it is January February and March
  3777. 2:24:27jobs are now inside of here so we
  3778. 2:24:29created tables using the extract
  3779. 2:24:32function now I always like to double
  3780. 2:24:34check my work so I'm going to run this
  3781. 2:24:35select statement right here where we
  3782. 2:24:37select job posted date from March jobs
  3783. 2:24:41running this pressing command e command
  3784. 2:24:43D we can see that all these different
  3785. 2:24:45jobs in here looks like we're around
  3786. 2:24:4764,000 different values and they're all
  3787. 2:24:49for Mar so I'm pretty confident that all
  3788. 2:24:52the other values should be correct all
  3789. 2:24:54right it's your turn to give it a try we
  3790. 2:24:55need to get these tables built inside of
  3791. 2:24:57your database cuz like I said we will be
  3792. 2:24:58using this in some future examples with
  3793. 2:25:01that see you in the next
  3794. 2:25:06one all right in this section we're
  3795. 2:25:08going over case expressions and this is
  3796. 2:25:10very common where if we want to create a
  3797. 2:25:12column based on a condition we can do
  3798. 2:25:15this through this case now if you have
  3799. 2:25:17any experience with something like
  3800. 2:25:19spreadsheets or even python on this is
  3801. 2:25:21very similar to an if statement where an
  3802. 2:25:23if a statement usually have some sort of
  3803. 2:25:26condition whether you're trying to test
  3804. 2:25:27whether it meets it true or false and
  3805. 2:25:29then from there it assigns it a value
  3806. 2:25:32whether it is in fact true or false so
  3807. 2:25:34let's go over the basic syntax on how to
  3808. 2:25:37use this and commonly it's used within a
  3809. 2:25:40select statement and that's we're going
  3810. 2:25:41to show here but you can use it in a
  3811. 2:25:43whole host of other things such as where
  3812. 2:25:44or even Group by to list an expression
  3813. 2:25:47to satisfy by case we start out with
  3814. 2:25:49case and then we end it with end and at
  3815. 2:25:52the end you can also use an alias so we
  3816. 2:25:54can have in this case as column
  3817. 2:25:56description so that's we're going to
  3818. 2:25:57name that column as whatever we build
  3819. 2:25:59with this now this is going to go in
  3820. 2:26:01logical order so for the first one of
  3821. 2:26:03when column name equals value one we're
  3822. 2:26:05going to check whether it does meet that
  3823. 2:26:07and if it does then we'll provide it
  3824. 2:26:10this value which will go inside that
  3825. 2:26:11column description column from there
  3826. 2:26:14we'll move to that next line of when
  3827. 2:26:16column name equals value two and then
  3828. 2:26:18description for column 2 and if it
  3829. 2:26:19doesn't meet any of those two conditions
  3830. 2:26:22it will meet the else condition of then
  3831. 2:26:24other and that will be what it will be
  3832. 2:26:27assigned so let's start simple with this
  3833. 2:26:29query where we're just going to look at
  3834. 2:26:30the job title short column and also the
  3835. 2:26:33job location column so let's look at a
  3836. 2:26:35condition where we would maybe want to
  3837. 2:26:38reclassify where a job is located at and
  3838. 2:26:42for this we need to look at the job
  3839. 2:26:43location column so I'm going to go ahead
  3840. 2:26:45and run this query by pressing command D
  3841. 2:26:47command D and inside of this job
  3842. 2:26:49location column we can see we have
  3843. 2:26:51things like either like a state city or
  3844. 2:26:54even a country City and then we even
  3845. 2:26:56have things for like remote jobs where
  3846. 2:26:59we specify that the job location is
  3847. 2:27:01anywhere so for the scenario I have
  3848. 2:27:04three different conditions I want to
  3849. 2:27:06look at I want to create a new column
  3850. 2:27:09and let's say I'm job searching I'm
  3851. 2:27:11located in New York and I want to label
  3852. 2:27:14things like anywhere jobs as remote if
  3853. 2:27:17they are in New York I want to label
  3854. 2:27:19them as as local and then otherwise I
  3855. 2:27:22just want to label it as onsite that you
  3856. 2:27:24have to be in that location so I'm just
  3857. 2:27:26going to disregard them so with any case
  3858. 2:27:28statement I'm going to start with that
  3859. 2:27:29case and then I'm also have the end and
  3860. 2:27:32the Alias we're going to use for this
  3861. 2:27:34one is location category now let's go
  3862. 2:27:37for that first statement of for anywhere
  3863. 2:27:40we want to label it as remote so when
  3864. 2:27:43job location is equal to anywhere I'm
  3865. 2:27:48going to go ahead and move this over a
  3866. 2:27:49little bit get this out of the way then
  3867. 2:27:51we'll label it as remote next when job
  3868. 2:27:55location equals New York New York then I
  3869. 2:27:58want it to label it as local and then
  3870. 2:28:00finally with everything else because
  3871. 2:28:02this goes in logical order and satisfies
  3872. 2:28:04whether it meets it I'm going to then
  3873. 2:28:06specify an else statement of onsite all
  3874. 2:28:09right let's go ahead and run this all
  3875. 2:28:11pressing command e command e okay I got
  3876. 2:28:13an error right here and that's because
  3877. 2:28:15we don't have a comma after job location
  3878. 2:28:18because it's starting that new column
  3879. 2:28:20so make sure you have that in there all
  3880. 2:28:22right command D command D expand this
  3881. 2:28:24out a little bit all right now we can
  3882. 2:28:26see the anywhere rows are now labeled as
  3883. 2:28:29remote the New York is located as local
  3884. 2:28:32and then everything else is on site so
  3885. 2:28:35this is great that know we have this
  3886. 2:28:36done but from an analysis standpoint I
  3887. 2:28:38want to dive into this further I want to
  3888. 2:28:41analyze how many jobs I have I can apply
  3889. 2:28:44to specifically the local ones and the
  3890. 2:28:46remote ones also look at the onsite as
  3891. 2:28:48well so we can use something like the
  3892. 2:28:50group by function in order to aggregate
  3893. 2:28:53all these different values so I'm going
  3894. 2:28:55to start by how we're going to aggregate
  3895. 2:28:56this and that's going to be using a
  3896. 2:28:58count and I'm going to use that job ID
  3897. 2:29:00column making sure to include a comma
  3898. 2:29:03also with this count job ID I'm just
  3899. 2:29:04going to label this appropriate as
  3900. 2:29:06number of jobs so let's first start by
  3901. 2:29:08just starting simple of doing a group ey
  3902. 2:29:10and we're going to be doing this using
  3903. 2:29:12that location category let's actually
  3904. 2:29:15run this query to see what we have so
  3905. 2:29:17far command D command D all right a lot
  3906. 2:29:19more onsite verse remote verse local not
  3907. 2:29:23bad for local 8,000 jobs in New York
  3908. 2:29:25anyway if you recall I specifically care
  3909. 2:29:28about the data analyst jobs so we'll
  3910. 2:29:31specify a filter for where and we'll TI
  3911. 2:29:34Go with the job title short equal to
  3912. 2:29:38data
  3913. 2:29:40analysis running this again seeing how
  3914. 2:29:43little we declined went from 8,000 jobs
  3915. 2:29:46to 3,000 jobs local and down to 13,000
  3916. 2:29:50what was it previously 69,000 okay now I
  3917. 2:29:53normally put an order Buy in here but it
  3918. 2:29:55looks like for some reason it
  3919. 2:29:56automatically sorted it from highest to
  3920. 2:29:58lowest so I'll consider this good enough
  3921. 2:30:00for now anyway we wanted to I could Dow
  3922. 2:30:02dive deeper into these 3,000 local jobs
  3923. 2:30:06that I could then apply to all right
  3924. 2:30:08with that it's your turn to give it a
  3925. 2:30:09try with case expressions for those that
  3926. 2:30:11bought the course certificate and notes
  3927. 2:30:13you now have a practice problem
  3928. 2:30:15specifically that goes into bucketing
  3929. 2:30:17different jobs specifically around
  3930. 2:30:20salaries so assigning different values
  3931. 2:30:22for each all right with that see you in
  3932. 2:30:24the next
  3933. 2:30:28one all right in this section we're
  3934. 2:30:30going to be going over both subqueries
  3935. 2:30:32and CTE and the concept behind both of
  3936. 2:30:36these are that we're going to create
  3937. 2:30:38basically temporary tables inside of our
  3938. 2:30:41SQL query that we're performing and then
  3939. 2:30:43perform and Analysis on this temporary
  3940. 2:30:46table this is very useful whenever we're
  3941. 2:30:48getting into more and more complex
  3942. 2:30:50queries that we need to be able to do as
  3943. 2:30:52we want to break it up into sections and
  3944. 2:30:55subqueries and CTE allow us to do this
  3945. 2:30:58now in order to show the power of
  3946. 2:30:59subqueries and CTE if you recall back
  3947. 2:31:03from one of our previous practice
  3948. 2:31:05problems of creating tables for each of
  3949. 2:31:07the different months we use this
  3950. 2:31:10statement of create table and then
  3951. 2:31:11underneath it for it we specify that we
  3952. 2:31:14wanted to only extract out those values
  3953. 2:31:17where the job posting date fell in
  3954. 2:31:19January in this case for the January
  3955. 2:31:20jobs and then from there it created a
  3956. 2:31:22table inside of our database this table
  3957. 2:31:25is sort of like permanent it's there now
  3958. 2:31:27the only way you get rid of it as we
  3959. 2:31:28drop it let's tackle subqueries first
  3960. 2:31:30because they're used for simpler queries
  3961. 2:31:33let's say in this case we wanted to
  3962. 2:31:36create a temporary table of January jobs
  3963. 2:31:39well a subquery is a query as you
  3964. 2:31:42guessed it inside of another query so in
  3965. 2:31:44this case we have a select star
  3966. 2:31:46statement and then from and then Within
  3967. 2:31:49paren es we're specifying that subquery
  3968. 2:31:53in our case we want to select only the
  3969. 2:31:55jobs where the job posting month is
  3970. 2:31:58January and then we rename this table as
  3971. 2:32:02January jobs navigating back over to VSS
  3972. 2:32:05code to actually see this in operation I
  3973. 2:32:07can select this all press command e
  3974. 2:32:09command e and when we we scroll over to
  3975. 2:32:13that job posted date we can see that
  3976. 2:32:16this is all the January so we did that
  3977. 2:32:18select star on our sub query now the
  3978. 2:32:20other popular way to create a temporary
  3979. 2:32:22table are common table expressions or
  3980. 2:32:25spoken as CTE and they can be used in
  3981. 2:32:29even more locations such as select
  3982. 2:32:31insert update or even delete with this
  3983. 2:32:34one CTE are defined first using the with
  3984. 2:32:38statement and then you're saying with
  3985. 2:32:41this new table name and then the Alias
  3986. 2:32:43as and then from there within a
  3987. 2:32:45parentheses we're then specifying the
  3988. 2:32:48entire query that we want to run to put
  3989. 2:32:51in this new table called January jobs
  3990. 2:32:54from there we can then run the next
  3991. 2:32:56query of Select star from January jobs
  3992. 2:33:00all right to show this actually in vs
  3993. 2:33:01code let's actually run this one so
  3994. 2:33:03command e command D and once again
  3995. 2:33:06rolling over to that job posting date to
  3996. 2:33:08make sure that it did it correctly and
  3997. 2:33:10yeah we can see all of them are from
  3998. 2:33:11January for this so let's jump into some
  3999. 2:33:14harder practice problems for each of
  4000. 2:33:16these first one we're going to focus on
  4001. 2:33:18is subquery remember that's a query with
  4002. 2:33:21inside another query and we can use it
  4003. 2:33:23in things like select from where or
  4004. 2:33:25having we're going to be doing an
  4005. 2:33:26example where using it inside of the
  4006. 2:33:28wear Clause because it's in this
  4007. 2:33:30parentheses think of order of operations
  4008. 2:33:33the inside the parentheses will be
  4009. 2:33:34executed first and then everything
  4010. 2:33:36around it will be operated second so
  4011. 2:33:38let's say I wanted to get a list of
  4012. 2:33:41companies that are offering jobs that
  4013. 2:33:43don't have any requirements for a degree
  4014. 2:33:46currently in our column of job no
  4015. 2:33:49mentioned we have a true or false value
  4016. 2:33:52and this says whether a degree is going
  4017. 2:33:54to be required or mentioned in the job
  4018. 2:33:57posting and it's located inside the job
  4019. 2:33:59posting fact table so let's actually go
  4020. 2:34:01ahead and just look at it real quick so
  4021. 2:34:02right now I'm pulling company IDs and
  4022. 2:34:04then the job no degree mentioned and for
  4023. 2:34:09this all these are going to be true now
  4024. 2:34:11if we remember back from our diagram of
  4025. 2:34:14the table going on here we have that job
  4026. 2:34:16postings fact table itself that has
  4027. 2:34:19whether a degree is mentioned or not and
  4028. 2:34:20we have that Company ID however we don't
  4029. 2:34:22have the company name in this that's in
  4030. 2:34:24a separate table so that's why actually
  4031. 2:34:26in this case the subquery is going to be
  4032. 2:34:28so powerful because we're can to run a
  4033. 2:34:31subquery to get the jobs that have the
  4034. 2:34:34associated Company ID for no degree
  4035. 2:34:35mention and then from there filter
  4036. 2:34:37inside of the company dim table so let's
  4037. 2:34:40make this into a subquery and we're
  4038. 2:34:42going to start with very simple first
  4039. 2:34:44we're going to add a select statement
  4040. 2:34:46and then we'll say company name which is
  4041. 2:34:49the column name that we want to look at
  4042. 2:34:51naming it as name for the table we're
  4043. 2:34:53going to be selecting that company name
  4044. 2:34:55from we want to use that company dim and
  4045. 2:34:58now this is we're going to enter in that
  4046. 2:35:00subquery we're going to specify where
  4047. 2:35:02that Company ID is in this subquery
  4048. 2:35:07itself now if you recall whenever we ran
  4049. 2:35:10just this I'm going to just select this
  4050. 2:35:11and run the query again command D we're
  4051. 2:35:14getting back in this a company ID and
  4052. 2:35:17then whether job note agree mention is
  4053. 2:35:19true in this case realistically this
  4054. 2:35:21column is not even necessary so I'm
  4055. 2:35:23actually going to clean it out and we're
  4056. 2:35:25going to go ahead and run this again
  4057. 2:35:27command D command e and same numbers 1 n
  4058. 2:35:3010 yeah this is what we saw previously
  4059. 2:35:32here so I know it's pulling the right
  4060. 2:35:34things so we're trying to say hey where
  4061. 2:35:37the company ID is within this table so
  4062. 2:35:39within this table we're going to only
  4063. 2:35:41want to return those company names that
  4064. 2:35:44are associated with it so let's run this
  4065. 2:35:47all pressing command e command e
  4066. 2:35:50uh company name does not exist oops I
  4067. 2:35:53have this backwards it's actually name
  4068. 2:35:56as company name my bad okay we'll run
  4069. 2:36:00this again command D command D and Bam
  4070. 2:36:02we can see all these different things I
  4071. 2:36:04just want to show this further that we
  4072. 2:36:06are actually getting the right data so
  4073. 2:36:07I'm going to insert in that company ID
  4074. 2:36:09and I'm going to do some clean up real
  4075. 2:36:11quick anyway let's run this again
  4076. 2:36:14command e command e okay we can see in
  4077. 2:36:18here 1 3 4 6 7 8 9 so these are all the
  4078. 2:36:20ones that are accepting it and I realize
  4079. 2:36:23now whenever we look at this one we're
  4080. 2:36:25not seeing those other numbers and I
  4081. 2:36:26think this is just by an order by an
  4082. 2:36:28issue so I'm going to fix this real
  4083. 2:36:29quick by although it doesn't really
  4084. 2:36:31matter it's just inside of here putting
  4085. 2:36:33an order bu and then specifying Company
  4086. 2:36:35ID then from there just running this
  4087. 2:36:38subquery inside of here pressing command
  4088. 2:36:40e command D okay we can see all the one
  4089. 2:36:43the same one so 1 3 4 6 and then
  4090. 2:36:48navigating over to the other one see 1 3
  4091. 2:36:504 6 so this is correlating and checking
  4092. 2:36:53out right and this is how you actually
  4093. 2:36:54should go through troubleshooting it
  4094. 2:36:56let's wrap up this section with a final
  4095. 2:36:57example on using CTE or comment table
  4096. 2:37:01Expressions this is used similar to a
  4097. 2:37:03subquery to create a temporary result
  4098. 2:37:06set which in this video previously I may
  4099. 2:37:09have been referring to it as a temporary
  4100. 2:37:10table that was a mistake it's a
  4101. 2:37:11temporary result set they're two
  4102. 2:37:13separate things anyway the results of
  4103. 2:37:15this temporary result set can be then
  4104. 2:37:17used in things like Cas select statement
  4105. 2:37:20insert update or even delete this only
  4106. 2:37:22exists during the execution of the query
  4107. 2:37:25and it's defined using a with statement
  4108. 2:37:28before it then defining the table and
  4109. 2:37:30then using as and then in closing all of
  4110. 2:37:32the in parenthesis how we want to create
  4111. 2:37:34this temporary result set we can then
  4112. 2:37:36call this within a query below it so
  4113. 2:37:40let's actually work a problem to see how
  4114. 2:37:41CDs are used for this we're going to be
  4115. 2:37:44finding the companies with the most job
  4116. 2:37:46openings now we need to break this up
  4117. 2:37:48into two parts and that's why CTS are
  4118. 2:37:50perfect for this because first we get
  4119. 2:37:52the need to get the total number of job
  4120. 2:37:54postings per Company ID which is located
  4121. 2:37:57inside of our fact table of job postings
  4122. 2:37:59fact but then once we have this total
  4123. 2:38:02number we then need to combine it with
  4124. 2:38:04the company name which was in the
  4125. 2:38:06company dim column so we're going to
  4126. 2:38:08start by building our query first for
  4127. 2:38:11that first bullet of getting the total
  4128. 2:38:13number of job postings per Company ID so
  4129. 2:38:15for any of these queries I want to just
  4130. 2:38:16start small we're going to be selecting
  4131. 2:38:18the company ID and looking at the what
  4132. 2:38:20comes back from this so we can see that
  4133. 2:38:22it has multiple different IDs in so now
  4134. 2:38:24we need to go into actually aggregating
  4135. 2:38:26it for this we're going to be using the
  4136. 2:38:28count function and we can just put in
  4137. 2:38:30there the asteris symbol is that's going
  4138. 2:38:31to count the number of rows but anytime
  4139. 2:38:33we're do an aggregation function we need
  4140. 2:38:35to specify the group by on how we're
  4141. 2:38:38going to be grouping it and in this case
  4142. 2:38:40we want to group it by what's given in
  4143. 2:38:42that table right there of that company
  4144. 2:38:44ID all right let's run this
  4145. 2:38:46one okay so now we have these counts so
  4146. 2:38:49we can actually just go back and verify
  4147. 2:38:51for zero we had four right here and it
  4148. 2:38:54looks like we have four returning so
  4149. 2:38:56this is the core statement that we're
  4150. 2:38:57going to be using inside of our CTE so
  4151. 2:39:00we can go ahead and create that now so I
  4152. 2:39:02Define this using a wi statement and
  4153. 2:39:04then give it a table name of company job
  4154. 2:39:07count using the Alias as and then inside
  4155. 2:39:09parentheses all the query that we want
  4156. 2:39:11to do and then just to get started and
  4157. 2:39:13making sure that this works properly I'm
  4158. 2:39:15just going to do a simple select from
  4159. 2:39:17statement to actually Define this and
  4160. 2:39:19this will just query this temporary
  4161. 2:39:21result set that we've defined up here
  4162. 2:39:24and running it we have the same results
  4163. 2:39:27that we had before now it's just through
  4164. 2:39:29that temporary result set so just
  4165. 2:39:31refresher on the schema we have that job
  4166. 2:39:34postings fact data that is connected to
  4167. 2:39:36our company dim table using a company ID
  4168. 2:39:40so we needed to use a join method in
  4169. 2:39:43order to combine these two tables
  4170. 2:39:45together to combine these two tables
  4171. 2:39:47we're going to be using a left join and
  4172. 2:39:50for this we want to use our a table make
  4173. 2:39:53sure we have everything from it as the
  4174. 2:39:55company dim table because maybe there
  4175. 2:39:57may be some companies that don't
  4176. 2:39:59necessarily have job postings that we
  4177. 2:40:01aggregated from the B table so we want
  4178. 2:40:03everything to be listed there so way if
  4179. 2:40:04there isn't there's a zero associated
  4180. 2:40:06with it that there's no job postings so
  4181. 2:40:08as you guessed it B is going to be the
  4182. 2:40:10fact table that we're going to be
  4183. 2:40:12combining to this so let's start simple
  4184. 2:40:15with this basic query down here and
  4185. 2:40:16we're just going to be looking at first
  4186. 2:40:18that comp company dim table and so just
  4187. 2:40:21running this query right here command D
  4188. 2:40:23command D we can see all the different
  4189. 2:40:25names from it so now that we have this
  4190. 2:40:27let's actually move into joining this
  4191. 2:40:30I'm going to do a left join specify that
  4192. 2:40:33temporary result set and then what we're
  4193. 2:40:35going to match these two left joins on
  4194. 2:40:38which is the company ID from each table
  4195. 2:40:40we're not going to necessarily get any
  4196. 2:40:41different results with this but I'm
  4197. 2:40:42going to go ahead and exate execute this
  4198. 2:40:43entire query to make sure it's actually
  4199. 2:40:45working properly okay it's working
  4200. 2:40:47properly now if you remember we want to
  4201. 2:40:48get the total number of job postings per
  4202. 2:40:50Company ID and have it basically
  4203. 2:40:53associated with a company name so this
  4204. 2:40:56is from the company dim table and I'm
  4205. 2:40:58going to rename this as company name so
  4206. 2:41:01I want this value from this count star
  4207. 2:41:03statement right now I don't have an Al
  4208. 2:41:05should have done that before so we're
  4209. 2:41:06just going to name this as total jobs
  4210. 2:41:09and then we want to have it appear in
  4211. 2:41:11this new query that we have here so I'm
  4212. 2:41:13going to then Define it okay let's
  4213. 2:41:16actually run this entire query Now
  4214. 2:41:19command e command e bam and now we have
  4215. 2:41:22the company names along with their total
  4216. 2:41:25number of jobs right now remember we
  4217. 2:41:28want to get at the highest who who has
  4218. 2:41:31the most so we need to now do an order
  4219. 2:41:32buy and I'll just add this here at the
  4220. 2:41:34bottom order bu total jobs in descending
  4221. 2:41:38order let's now rerun this query boom
  4222. 2:41:42all right now we got it and it looks
  4223. 2:41:44like umgo is one of the highest amount
  4224. 2:41:48along with other popular companies like
  4225. 2:41:49city capital 1 Walmart and centure so
  4226. 2:41:53yeah all right it's now your turn to
  4227. 2:41:54give it a try and I have for those that
  4228. 2:41:57purchas the course certificat notes I
  4229. 2:41:58have multiple different practice
  4230. 2:41:59problems that you can go to three for
  4231. 2:42:01subqueries and three also for CTE if
  4232. 2:42:04you're still not feeling confident on
  4233. 2:42:06actually tackling these problems on your
  4234. 2:42:07own just stand by because in the next
  4235. 2:42:09section we're going to do uh go into
  4236. 2:42:11another problem of using CTE and a
  4237. 2:42:15pretty fun example so feel free to even
  4238. 2:42:17hold off until after that section all
  4239. 2:42:19right with that see you in the next
  4240. 2:42:25one all right let's get into a practice
  4241. 2:42:27problem of how to use CTS even further
  4242. 2:42:30than the previous examples for this we
  4243. 2:42:33have a pretty exciting example that
  4244. 2:42:34Kelly came up with and this problem was
  4245. 2:42:36inspired by my app. nerd. te that
  4246. 2:42:39Aggregates job posting skills depending
  4247. 2:42:42on a different job title you want to
  4248. 2:42:44look at so if I wanted to look at
  4249. 2:42:45something like data analyst we could see
  4250. 2:42:47what are the top results here anyway
  4251. 2:42:49Kelly came with this problem find the
  4252. 2:42:50count of the number of remote job
  4253. 2:42:53postings per skill so we're going to be
  4254. 2:42:55focusing specifically on this cuz say in
  4255. 2:42:57my case I'm a data analyst looking for
  4256. 2:42:59remote jobs and that's what I care about
  4257. 2:43:01most we'll display the top five skills
  4258. 2:43:03by their demand and then include other
  4259. 2:43:05attributes like skill ID name and the
  4260. 2:43:07count of job postings now how are we
  4261. 2:43:09going to tackle this well remember the
  4262. 2:43:12job postings fact table has all of our
  4263. 2:43:14different job postings but it doesn't
  4264. 2:43:16have necessarily all the different
  4265. 2:43:17skills in here instead we have to use
  4266. 2:43:20that skills job dimm table to get the
  4267. 2:43:22all the different correlated jobs to
  4268. 2:43:24skills and then our final skills
  4269. 2:43:26dimensional table that includes the name
  4270. 2:43:29of those skills so the first thing we're
  4271. 2:43:31going to do is build a CTE that
  4272. 2:43:34basically collects the number of job
  4273. 2:43:36postings per skill so we're going to
  4274. 2:43:38have to do some sort of join between our
  4275. 2:43:40job posting fact table and our skills
  4276. 2:43:42job dim table once we have this
  4277. 2:43:44temporary result set we can then take
  4278. 2:43:47this a step further and then combine it
  4279. 2:43:49with our skills dim table to actually
  4280. 2:43:52give us our final results that have the
  4281. 2:43:54skill name in it for all the joins
  4282. 2:43:56within this portion we are trying to get
  4283. 2:43:59a count of jobs that actually exist we
  4284. 2:44:02don't really necessarily care about if
  4285. 2:44:04there's values that don't exist so for
  4286. 2:44:06this we're going to find that inner join
  4287. 2:44:08is the best method to use for this so
  4288. 2:44:10let's start with the very Basics and
  4289. 2:44:12then build upon there for the CTE I just
  4290. 2:44:14want to look at first the skill ID
  4291. 2:44:17column of the skill from the skills to
  4292. 2:44:19job dim table which we're going to just
  4293. 2:44:21conveniently rename skills to job
  4294. 2:44:25command e command e all right so we're
  4295. 2:44:27already seeing repeats in here I'm going
  4296. 2:44:29to go ahead and just actually showcase
  4297. 2:44:31the job ID column as well put a common
  4298. 2:44:34in there run this query again so we can
  4299. 2:44:36actually see this better because I don't
  4300. 2:44:38think it's like showing fully what we
  4301. 2:44:39want to see all right this one's much
  4302. 2:44:41better this one has so for the job ID
  4303. 2:44:43let's say zero which is one of the job
  4304. 2:44:45IDs it has the skill ID Associated of it
  4305. 2:44:48of zero and one so there's multiple
  4306. 2:44:51skills associated with this job so let's
  4307. 2:44:53go ahead and actually join this on our
  4308. 2:44:56job postings fact table since that we
  4309. 2:44:58know that they're correlated through
  4310. 2:44:59that job ID column so the first thing we
  4311. 2:45:01do is specify in join after that from
  4312. 2:45:03statement soing the table and we're
  4313. 2:45:05going to rename it just simply as job
  4314. 2:45:07postings from there we're going to
  4315. 2:45:08specify how we're going to connect this
  4316. 2:45:10and we're connecting it on the job ID I
  4317. 2:45:12want to make sure this works so I'm
  4318. 2:45:13going to just do command e command D and
  4319. 2:45:15job ID is ambiguous so I need to specify
  4320. 2:45:18right because it's both of the skills to
  4321. 2:45:20job and the job postings doesn't really
  4322. 2:45:22matter which one we specify we're going
  4323. 2:45:24to just specify this one right here and
  4324. 2:45:26then run this query again all right so
  4325. 2:45:29the query is running there's nothing
  4326. 2:45:31necessarily new in here that we've
  4327. 2:45:33included but if you recall we want to
  4328. 2:45:37look at or filter for the jobs that have
  4329. 2:45:40work from home as true or remote jobs so
  4330. 2:45:44the first thing I do is just add to the
  4331. 2:45:46select statement to actually see it
  4332. 2:45:48shown in here
  4333. 2:45:49and it looks like we got a lot of false
  4334. 2:45:51results I'm sure we'll eventually get
  4335. 2:45:54some true oh we got a True Result right
  4336. 2:45:55here so let's actually now Define that
  4337. 2:45:57where to meet this portion of the
  4338. 2:45:59question of remote jobs and we want to
  4339. 2:46:01specify where job postings of job work
  4340. 2:46:05from home is equal to True ring this
  4341. 2:46:08query again all right so they're all
  4342. 2:46:10true in this case we don't need this
  4343. 2:46:12column anymore listed here so I'm going
  4344. 2:46:14to go ahead and delete it I just
  4345. 2:46:16showcase it to make sure that we were
  4346. 2:46:17building the query correctly
  4347. 2:46:19now getting back to that core problem we
  4348. 2:46:20want to get the count of the number of
  4349. 2:46:22remote job postings per skill so we have
  4350. 2:46:25this skill ID already we need to now get
  4351. 2:46:29a count and we're going to be doing that
  4352. 2:46:32count star method we'll sign this at an
  4353. 2:46:34alas of skill count anytime we do an
  4354. 2:46:38aggregation well we need to do a group
  4355. 2:46:40by and we're wanting to group it by
  4356. 2:46:42obviously that skill ID now since we're
  4357. 2:46:46combining by this skill ID and do this
  4358. 2:46:47aggregation this job ID column is no
  4359. 2:46:50longer useful and actually we'll throw
  4360. 2:46:51off our aggregation so we're going to go
  4361. 2:46:53ahead and get rid of it and we're going
  4362. 2:46:54to go ahead and run this query all right
  4363. 2:46:57so now we're seeing that skill ID and
  4364. 2:46:58skill count I can see here that skill
  4365. 2:47:01count these this zero and one Whatever
  4366. 2:47:03skills they are associated with the IDS
  4367. 2:47:05are this high right here at
  4368. 2:47:0740,000 so we pretty much have our CTE
  4369. 2:47:10built so let's go ahead and build that
  4370. 2:47:12CT out using that wi statement defining
  4371. 2:47:15it as remote job skills and then using
  4372. 2:47:18the alien operator to put that all
  4373. 2:47:20inside of there so now that we've
  4374. 2:47:22combined that job postings fact with
  4375. 2:47:24that skills job dim table and we have
  4376. 2:47:27this in a common table with a skill ID
  4377. 2:47:31for it we can now go further and do
  4378. 2:47:33another inner join with this CTE to that
  4379. 2:47:37skills dim table so the first thing I'm
  4380. 2:47:39going to do is just make sure that this
  4381. 2:47:40CTE works by just doing a select star of
  4382. 2:47:43this remote job skills running this
  4383. 2:47:45query I can see that it works so let's
  4384. 2:47:48move into actually doing that inner join
  4385. 2:47:50with the skills dim table I specify
  4386. 2:47:52inner join and then the table assigning
  4387. 2:47:55the Alias of skill and we're going to
  4388. 2:47:58connect both of these on that skill ID
  4389. 2:48:01column and now that it connected we need
  4390. 2:48:03to specify the columns we want for this
  4391. 2:48:05so the first we'll just keep it simple
  4392. 2:48:07with only the skill ID but obviously
  4393. 2:48:09next we want the skill name with that
  4394. 2:48:11defined we need to now have the most
  4395. 2:48:13important value skill count so let's go
  4396. 2:48:15ahead and see if this entire query works
  4397. 2:48:19then looks like I have an error here I
  4398. 2:48:21referred to the table in join as skill
  4399. 2:48:24when I reference it up here as skill so
  4400. 2:48:26we're just going to go ahead and add
  4401. 2:48:27Nest that whoopsies and we going to
  4402. 2:48:29select this whole statement again and
  4403. 2:48:31run it again all right so now we have
  4404. 2:48:33that skill ID skill name and then the
  4405. 2:48:35skill count couple things we are left to
  4406. 2:48:37do now is actually order this and then
  4407. 2:48:40remember we only need the top five
  4408. 2:48:42results so we'll add an order by
  4409. 2:48:44statement right here specifying that we
  4410. 2:48:46want to order it by that skill count in
  4411. 2:48:49descending order and then we only want
  4412. 2:48:51the top five results so I'm just going
  4413. 2:48:53to throw in a limit statement right here
  4414. 2:48:55selecting all this query and then
  4415. 2:48:57pressing command e command D bam now we
  4416. 2:49:00got it and we can see what were those
  4417. 2:49:0140,000 values now it was obviously
  4418. 2:49:04Python and then SQL followed next by AWS
  4419. 2:49:07Azure and Spark now I'm going to throw
  4420. 2:49:09one simple caveat to this question
  4421. 2:49:12because frankly I really care about data
  4422. 2:49:14analyst jobs so I'm going to filter our
  4423. 2:49:16CTE further for only data analyst jobs
  4424. 2:49:18JS using within that and within the wear
  4425. 2:49:21statement and and specifically where
  4426. 2:49:24that job title short equals data analyst
  4427. 2:49:27all right let's go ahead and run this
  4428. 2:49:29all to see what it looks like for data
  4429. 2:49:31analyst and Bam these are more of
  4430. 2:49:33results that I would expect for data
  4431. 2:49:36analyst CU well that's the query anyway
  4432. 2:49:38we got SQL Excel and then python Tableau
  4433. 2:49:40and powerbi so regardless of what you're
  4434. 2:49:43filtering for it goes to show the
  4435. 2:49:44importance of SQL this is the top skill
  4436. 2:49:48and so I think it's beoo of you that
  4437. 2:49:49you've spent the time to learn this all
  4438. 2:49:51right for those that purchased the
  4439. 2:49:52course certificates and notes feel free
  4440. 2:49:54to go ahead if you haven't already to
  4441. 2:49:56work those practice problems working
  4442. 2:49:58through those example problems for CTE
  4443. 2:50:00and also subqueries and once you're done
  4444. 2:50:03with that we'll be moving into the last
  4445. 2:50:04major topic of this Advanced section
  4446. 2:50:07focusing on unions with that see you in
  4447. 2:50:10the next
  4448. 2:50:15one all right welcome to this last major
  4449. 2:50:18topic we'll be covering in the advanced
  4450. 2:50:19section on unions this is very important
  4451. 2:50:23for combining tables it's directly if
  4452. 2:50:25you will opposite of how we're doing
  4453. 2:50:27joins so joins are used in the case
  4454. 2:50:30whenever we want to combine tables that
  4455. 2:50:34maybe relate on a single value such as
  4456. 2:50:37in the case of combining like the job
  4457. 2:50:39posting fact table with the company dim
  4458. 2:50:41table we're going to combine this on the
  4459. 2:50:43company ID column now if you remember
  4460. 2:50:45previously we created three taable
  4461. 2:50:49for those job postings in January
  4462. 2:50:52February and March I'm moving this over
  4463. 2:50:55here so we can actually see it better
  4464. 2:50:57the January table has the same columns
  4465. 2:51:00as that February table along with that
  4466. 2:51:03March table so in this case if we wanted
  4467. 2:51:06to combine these basically rowwise we
  4468. 2:51:10could use a union operator to do this so
  4469. 2:51:13the first we're going to cover is Union
  4470. 2:51:15and it comines the results from two or
  4471. 2:51:18more or select statements you would use
  4472. 2:51:20this operator by first defining a
  4473. 2:51:23statement such as select column name
  4474. 2:51:24from table one and then specifying Union
  4475. 2:51:28and then underneath it specifying the
  4476. 2:51:30next table you want to do it select
  4477. 2:51:31column name from table two and now in
  4478. 2:51:33order to Union this there is one
  4479. 2:51:35specific condition this has to meet they
  4480. 2:51:37have to have the same number amount of
  4481. 2:51:39columns in this case we're only doing
  4482. 2:51:41one column here but in our January
  4483. 2:51:44February March jobs they can have a
  4484. 2:51:46multitude of columns they just all have
  4485. 2:51:48to match and they all have to be the
  4486. 2:51:50same data type and the last thing to
  4487. 2:51:52note is it gets rid of all duplicate
  4488. 2:51:54rows whenever you combine this unlike
  4489. 2:51:56the next operator Union all so let's
  4490. 2:51:58start with this simple query I want to
  4491. 2:52:01look into seeing all the different job
  4492. 2:52:04titles and Company IDs and job locations
  4493. 2:52:07for the month of January these are the
  4494. 2:52:10main although they're not all the
  4495. 2:52:11columns are the main attributes that I
  4496. 2:52:12care about I'm going go ahead and run
  4497. 2:52:15this query just make sure that it runs
  4498. 2:52:16perfectly fine and we can see here here
  4499. 2:52:18all the different results that we're
  4500. 2:52:20seeing from it so now let's actually
  4501. 2:52:22join this with our February jobs table
  4502. 2:52:24first I'm going to specify Union then
  4503. 2:52:27I'm going to do another select statement
  4504. 2:52:29for the February jobs and I'm making
  4505. 2:52:31sure that I have the exact same columns
  4506. 2:52:33listed as the January jobs right now
  4507. 2:52:36from January jobs we have around 92,000
  4508. 2:52:39jobs if we run this all together we can
  4509. 2:52:42see now we have over
  4510. 2:52:45107,000 jobs so let's just take this a
  4511. 2:52:48step further and now add in all of the
  4512. 2:52:51March jobs so we have now January
  4513. 2:52:54February March and we're specifying all
  4514. 2:52:55the different columns how many jobs are
  4515. 2:52:57we going to have return and for this one
  4516. 2:52:59now we're up to 143,000 jobs so that's
  4517. 2:53:03the union keyword moving on to Union all
  4518. 2:53:06it's pretty much used in the same exact
  4519. 2:53:08way we're still using two or more select
  4520. 2:53:11statements in order to combine different
  4521. 2:53:13tables and they need to have whenever
  4522. 2:53:15we're doing this the same amount of
  4523. 2:53:16columns and the same data type now the
  4524. 2:53:18thing about the keyword all of Union all
  4525. 2:53:20is that it returns all rows even
  4526. 2:53:22duplicates and Kelly and I have talked
  4527. 2:53:24about this further and we find that we
  4528. 2:53:26use mostly this one in our jobs as we
  4529. 2:53:29typically want to get all the data back
  4530. 2:53:31to make sure we're looking at everything
  4531. 2:53:33so going back to that previous query
  4532. 2:53:34that we built here all this takes is
  4533. 2:53:37adding in all to both of these now
  4534. 2:53:40remember the previous query we got
  4535. 2:53:42around 143,000 results so let's see what
  4536. 2:53:46we're going to get back with this Union
  4537. 2:53:48all we should be getting back more
  4538. 2:53:50values and we do looks like
  4539. 2:53:54220,000 so quite a bit more than this
  4540. 2:53:58almost 880,000 more values or 880,000
  4541. 2:54:00duplicates if you will all right now
  4542. 2:54:02it's your turn to give it a try we have
  4543. 2:54:04a few practice problems built in order
  4544. 2:54:07to implement both the union and the
  4545. 2:54:09union all if you're still not
  4546. 2:54:11comfortable with either of these I do
  4547. 2:54:13have a practice problem coming up where
  4548. 2:54:14I'm using Union also in combination with
  4549. 2:54:17some other things like subqueries and
  4550. 2:54:19CTE so you can feel free to hold off
  4551. 2:54:21until after that practice problem if
  4552. 2:54:23you're not exactly comfortable yet with
  4553. 2:54:25unions all right with that see you in
  4554. 2:54:27the next
  4555. 2:54:33one all right let's dive into the last
  4556. 2:54:35practice problem of this Advanced
  4557. 2:54:37section before we actually dive into our
  4558. 2:54:39project for this I want to do an
  4559. 2:54:41analysis of the job postings from the
  4560. 2:54:43first quarter that have salary greater
  4561. 2:54:46than $70,000 that's like my target range
  4562. 2:54:49right now so we have those tables
  4563. 2:54:50already on January February March we're
  4564. 2:54:52going to use our Union operators to
  4565. 2:54:55combine them all and then we're going to
  4566. 2:54:57be using it within a subquery to then
  4567. 2:55:00analyze it allowing us to thus filter it
  4568. 2:55:02for those jobs greater than 7,000 and
  4569. 2:55:05get a snapshot of the jobs we actually
  4570. 2:55:06want so anytime we're building a
  4571. 2:55:07subquery or CTE I like to just tackle it
  4572. 2:55:10first for this we're going to be
  4573. 2:55:11selecting all the different columns from
  4574. 2:55:14each of these different months tables so
  4575. 2:55:17I'm going to go ahead and just run right
  4576. 2:55:18here to show what it looks like okay and
  4577. 2:55:21we can see that it has all the different
  4578. 2:55:23columns associated with it so the next
  4579. 2:55:25thing we need to do is specify that
  4580. 2:55:27Union and we're going to use all because
  4581. 2:55:29we don't want to remove any duplicates
  4582. 2:55:31and then once again specify the next
  4583. 2:55:33select statement for the February jobs
  4584. 2:55:35and then our final Union all statement
  4585. 2:55:37so we can combine this finally with our
  4586. 2:55:39March jobs let's actually combine this
  4587. 2:55:40all and see how many jobs we actually
  4588. 2:55:44have here all right and it looks like we
  4589. 2:55:47have around 200 200
  4590. 2:55:4912,000 which checks with what we did
  4591. 2:55:52last time so let's go ahead and start
  4592. 2:55:54building this into a subquery so I'm
  4593. 2:55:57must do select star and then from and
  4594. 2:56:00then build this Union all portion into
  4595. 2:56:03the subquery now because we defined this
  4596. 2:56:06table I'm going to give it an alias of
  4597. 2:56:08quarter 1 job postings let's go ahead
  4598. 2:56:11and run this again make sure that it's
  4599. 2:56:13working just properly okay sweet still
  4600. 2:56:15returning all the different jobs all
  4601. 2:56:17right I don't want all of these
  4602. 2:56:19different columns here so instead what
  4603. 2:56:22I'm going to do is I'm going to define
  4604. 2:56:23the four main Columns of interest for
  4605. 2:56:25this we're going to be doing job tile
  4606. 2:56:26short job location job via and the job
  4607. 2:56:29posted date specifically only the date
  4608. 2:56:32and then remember the last portion of
  4609. 2:56:34this question is that we want to find
  4610. 2:56:37the job postings that have an average
  4611. 2:56:38yearly salary greater than 70,000 so
  4612. 2:56:41with all of this I need to add a filter
  4613. 2:56:43on it using a wear statement we're going
  4614. 2:56:45to specify all this for greater than 70
  4615. 2:56:48,000 going ahead and running this all
  4616. 2:56:51command e command e boom we now have all
  4617. 2:56:53this information I'm going to modify
  4618. 2:56:56this further mainly two things one I
  4619. 2:56:58want to see the salary and two I really
  4620. 2:57:01only care about that iist jobs so the
  4621. 2:57:03first thing I add is quarter one job
  4622. 2:57:05postings and then I'm going to specify
  4623. 2:57:06that salary year average and then inside
  4624. 2:57:09of our weer statement I'm going to use
  4625. 2:57:11that and keyboard and specify where the
  4626. 2:57:15job title short is equal to data analyst
  4627. 2:57:19also one other bonus I'm just going to
  4628. 2:57:21throw in an order bu so that way we have
  4629. 2:57:23this listed for the salaries from
  4630. 2:57:26highest to lowest okay let's go ahead
  4631. 2:57:29and run this bad
  4632. 2:57:32boy bam now we have all these different
  4633. 2:57:35jobs and I can see that I need to apply
  4634. 2:57:38for y combinator and it's a remote job
  4635. 2:57:40that pays
  4636. 2:57:43$650,000 now I went ahead and removed
  4637. 2:57:45this table name prior to to these column
  4638. 2:57:49names some of you may run into problems
  4639. 2:57:50if you don't include this but I didn't
  4640. 2:57:52run into problems with it so I believe
  4641. 2:57:54shorter and brevity is better in all the
  4642. 2:57:56cases if I go ahead and remove that all
  4643. 2:57:58for all those different cases make this
  4644. 2:57:59look a little bit more concise running
  4645. 2:58:01this query I still get those same
  4646. 2:58:03results all right now it's your turn
  4647. 2:58:05we're going wrap up this final problem
  4648. 2:58:06so we can finally moved into that
  4649. 2:58:08portfolio project we're building with
  4650. 2:58:10that see you in the next
  4651. 2:58:11one then nerds welcome to the project
  4652. 2:58:14section of this course so you've already
  4653. 2:58:17learned so much in the basics and also
  4654. 2:58:19Advanced section with using SQL queries
  4655. 2:58:22but now it's actually time to put all
  4656. 2:58:25that knowledge to the test by building a
  4657. 2:58:27Capstone project now there's a few goals
  4658. 2:58:30with this project we're going to be
  4659. 2:58:32working with that same data set that we
  4660. 2:58:35built inside of the advanced section and
  4661. 2:58:37exploring it further and your goal for
  4662. 2:58:39this is twofold you're going to be
  4663. 2:58:41looking to analyze what are some of the
  4664. 2:58:43most top paying roles and also skills
  4665. 2:58:47but there's going to be a list catch to
  4666. 2:58:48this similar to the previous queries you
  4667. 2:58:50don't have to necessarily limit this
  4668. 2:58:52search and follow exactly like I do
  4669. 2:58:54searching for data analyst remote jobs
  4670. 2:58:56you can actually fine-tune it to your
  4671. 2:58:59job of choice Additionally you can
  4672. 2:59:01change it to things like the location
  4673. 2:59:03you are within the world you should need
  4674. 2:59:05to research into the data itself and
  4675. 2:59:07find a close enough location or
  4676. 2:59:09locations so for this there's going to
  4677. 2:59:10be a few different deliverables that
  4678. 2:59:12you're going to be able to Showcase as
  4679. 2:59:14experience with the work that you've
  4680. 2:59:15done I'm going to show it here within
  4681. 2:59:17the project SQL folder that you're going
  4682. 2:59:20to be building and I have five files
  4683. 2:59:22here for the five different queries
  4684. 2:59:23we're actually going to be diving into
  4685. 2:59:25and finding further insights about not
  4686. 2:59:28only roles but also skills for top
  4687. 2:59:31paying jobs additionally with this we're
  4688. 2:59:33going to be building out your own
  4689. 2:59:35personal read me file and this is
  4690. 2:59:37basically a descriptor of the project
  4691. 2:59:39itself and it's going to go in and
  4692. 2:59:41actually showcase all the different
  4693. 2:59:43analysis you did and besides just
  4694. 2:59:45analysis we can also go as far to show
  4695. 2:59:48show some of the results that we find
  4696. 2:59:49from it and we're going to be using
  4697. 2:59:51everything that we find in order to draw
  4698. 2:59:53some conclusions and help you out in
  4699. 2:59:55finding out what are the most optimal
  4700. 2:59:57roles and skills you should be pursuing
  4701. 3:00:00so this project can not only be
  4702. 3:00:01rewarding for those looking to learn SQL
  4703. 3:00:03but also maybe if you're job searching
  4704. 3:00:05or looking for promotion you may able to
  4705. 3:00:07find insights within this data set and
  4706. 3:00:10use it in your real life now all this
  4707. 3:00:12work you did is great but if you just
  4708. 3:00:13keep it on your computer and don't tell
  4709. 3:00:15anybody about it does really no good so
  4710. 3:00:17we're going to be working on this also
  4711. 3:00:19by showcasing this to things like GitHub
  4712. 3:00:22and Linkedin both of these sections
  4713. 3:00:24using GitHub and Git along with LinkedIn
  4714. 3:00:27are completely optional so whenever we
  4715. 3:00:29get to these one of these sections I'll
  4716. 3:00:31call it out and let you know that hey
  4717. 3:00:33this section we're working on building a
  4718. 3:00:35repository you don't need to pay
  4719. 3:00:36attention to it if you don't want to but
  4720. 3:00:38I highly recommend that you do anyway
  4721. 3:00:40with GitHub we're going to be actually
  4722. 3:00:42able to Showcase not only all the
  4723. 3:00:44different SQL that we have which are all
  4724. 3:00:46these different files right here but
  4725. 3:00:48we'll be able to Showcase mainly that
  4726. 3:00:50readme that we built to Showcase all the
  4727. 3:00:52different work that we did and our
  4728. 3:00:53findings and you may be wondering what
  4729. 3:00:55questions are we actually going to be
  4730. 3:00:56exploring for this well they all revolve
  4731. 3:00:59around top paying jobs and also skills
  4732. 3:01:02and so we'll be building on each one of
  4733. 3:01:04these with each of the queries we do and
  4734. 3:01:07finally ending up with probably the most
  4735. 3:01:09exciting one trying to identify the most
  4736. 3:01:11optimal skill something that's a high
  4737. 3:01:13demand and also high paying we're going
  4738. 3:01:16to dive much further into this after the
  4739. 3:01:18next section we're going to be actually
  4740. 3:01:20creating our project repository to thus
  4741. 3:01:22upload into GitHub one quick note for
  4742. 3:01:25those that bought the course notes and
  4743. 3:01:26certificates inside of your notes you're
  4744. 3:01:29going to have access to the questions
  4745. 3:01:32and all the different problems that
  4746. 3:01:33we're trying to solve with it in
  4747. 3:01:35addition to this we're going to break it
  4748. 3:01:37down even further inside of here by
  4749. 3:01:39including things like the reasoning so
  4750. 3:01:41what's going on behind each step of the
  4751. 3:01:44query and why we're doing each step
  4752. 3:01:46along with the final query itself and
  4753. 3:01:49what expected results you should be
  4754. 3:01:51finding all right in the next video
  4755. 3:01:52we're going to be diving into actually
  4756. 3:01:54setting up your GitHub account and
  4757. 3:01:56setting up the project repository so we
  4758. 3:01:58can get this thing started to host
  4759. 3:02:00online so we after we get it completely
  4760. 3:02:01built we'll be able to put it all there
  4761. 3:02:04like I said at the beginning this
  4762. 3:02:06portion of the GitHub integration is
  4763. 3:02:08completely optional but you learn a
  4764. 3:02:11highly valuable skill of git so I do
  4765. 3:02:13recommend that you do it all right with
  4766. 3:02:16that I'll see you in the next one
  4767. 3:02:22so what is a repository well it's a
  4768. 3:02:26personal library for your project where
  4769. 3:02:27you can keep manage and record every
  4770. 3:02:29change if you know of track changes in
  4771. 3:02:32Microsoft Word this is very similar to
  4772. 3:02:35that so how does this version control
  4773. 3:02:37work well there's a special folder
  4774. 3:02:41inside of your project that we're going
  4775. 3:02:42to be installing that's going to track
  4776. 3:02:44all the changes that go through it here
  4777. 3:02:47I have another data science project
  4778. 3:02:49inside of my finder window and it has
  4779. 3:02:51all the different contents that are
  4780. 3:02:52necessarily visible to me but in this
  4781. 3:02:55one there's actually some hidden files
  4782. 3:02:57there's this one for vs code we don't
  4783. 3:02:58really care about we care about this one
  4784. 3:03:00right here onget and that's how we're
  4785. 3:03:03going to be maintaining our Version
  4786. 3:03:04Control inside of this folder it tracks
  4787. 3:03:07all the different changes that we're
  4788. 3:03:09going to be doing to our project
  4789. 3:03:11exploring the contents of this is sort
  4790. 3:03:13of out of the scope and probably above
  4791. 3:03:14my PR grade but it's just important to
  4792. 3:03:16understand the purpose of this folder so
  4793. 3:03:19on our local computer ourself we have
  4794. 3:03:21this project or if you will a working
  4795. 3:03:24directory and then as we're working on
  4796. 3:03:26it and collecting new documents it's
  4797. 3:03:28going to go into a staging area and once
  4798. 3:03:30we have something we want to save or
  4799. 3:03:32commit we can then do that and it will
  4800. 3:03:35save to our local repository which is in
  4801. 3:03:37that dogit file now all of this is on
  4802. 3:03:40our local machine or our computer
  4803. 3:03:43locally but let's say we wanted to
  4804. 3:03:45collaborate with others or even share
  4805. 3:03:47this like we're going to be sharing with
  4806. 3:03:48this project we could then host it to
  4807. 3:03:51something like GitHub in this case it
  4808. 3:03:53will then host a copy of all of the
  4809. 3:03:56different content that we have locally
  4810. 3:03:59on our machine so in that case where I
  4811. 3:04:00showed you my previous project that
  4812. 3:04:02located here on my machine I can also go
  4813. 3:04:05up to GitHub and this is where I'm
  4814. 3:04:07actually hosting that same content at
  4815. 3:04:10this is would be my remote repository so
  4816. 3:04:13let's actually get into doing this for
  4817. 3:04:14our project and there's a few steps
  4818. 3:04:16we're going to be walking through for
  4819. 3:04:18this the first if you haven't done it
  4820. 3:04:20already we're going to go through and
  4821. 3:04:21actually install git git is the most
  4822. 3:04:24popular version control system so we're
  4823. 3:04:26going to be using it for this next we're
  4824. 3:04:28going to be diving into setting up a
  4825. 3:04:29GitHub account if you don't have one
  4826. 3:04:31already and it's pretty simple once we
  4827. 3:04:33have that we can now get into actually
  4828. 3:04:36initializing a repository within our
  4829. 3:04:39project so basically we're going to be
  4830. 3:04:40creating that dogit folder inside of our
  4831. 3:04:43project and then now that we have this
  4832. 3:04:45local repository we're going to want to
  4833. 3:04:48push this repository into GitHub and
  4834. 3:04:51thus we're going to have a remote
  4835. 3:04:53repository for the world to see so let's
  4836. 3:04:55get into download and git don't be
  4837. 3:04:56afraid if you're unsure if you have git
  4838. 3:04:59installed or not as reinstalling it's
  4839. 3:05:02not going to cause any issues anyway
  4840. 3:05:04navigate to this URL that's on the
  4841. 3:05:06screen right here or just simply Google
  4842. 3:05:09get download and it should navigate you
  4843. 3:05:11to this page from here select the
  4844. 3:05:14operating system of choice that has
  4845. 3:05:16yours and download it for Windows it's
  4846. 3:05:19pretty simple as you're going to walk
  4847. 3:05:21through a similar download process that
  4848. 3:05:23you did like postgress and it'll take
  4849. 3:05:25you through all the steps of the process
  4850. 3:05:26and you'll have it installed for Mac
  4851. 3:05:28users like me it's a little bit more
  4852. 3:05:30complicated you're going to want to open
  4853. 3:05:32up your
  4854. 3:05:35terminal and then from there insert this
  4855. 3:05:38Brew install git and you're going to
  4856. 3:05:41press enter and execute it now if you
  4857. 3:05:43don't have home brew you're going to
  4858. 3:05:44navigate to the link here that it has
  4859. 3:05:47and and once again it's very simple
  4860. 3:05:49you're going to just copy this command
  4861. 3:05:51that it gives you right here for
  4862. 3:05:52installing home brew and then inside of
  4863. 3:05:55your terminal paste it and run this
  4864. 3:05:57command then once you have home brew
  4865. 3:05:59installed you run this other command of
  4866. 3:06:00Brew install G anyway I promise you
  4867. 3:06:02that's the last time you'll see the
  4868. 3:06:03command line for this course now that
  4869. 3:06:05gets installed we need to move into
  4870. 3:06:07creating your GitHub account if you
  4871. 3:06:09don't have one already because you need
  4872. 3:06:11an account in order to host your
  4873. 3:06:13repository here's my GitHub account
  4874. 3:06:14right here has information about me and
  4875. 3:06:17all my different Social Links and then
  4876. 3:06:18from there it has all the different
  4877. 3:06:20projects I've worked on here along with
  4878. 3:06:22um more of them in this one right here
  4879. 3:06:25so you're going to navigate over to
  4880. 3:06:26github.com
  4881. 3:06:28signup and it will walk you through the
  4882. 3:06:31setup process to set up your account
  4883. 3:06:33inside of GitHub once you have this
  4884. 3:06:35account set up I'd go in and actually
  4885. 3:06:37edit your profile putting a picture in
  4886. 3:06:40and then updating all the relevant
  4887. 3:06:41information that you want to include on
  4888. 3:06:43your profile all right so we have git
  4889. 3:06:45installed on our computer and we have
  4890. 3:06:47have our GitHub account now we need to
  4891. 3:06:50move into actually creating that local
  4892. 3:06:53repository and then pushing it to GitHub
  4893. 3:06:55for our remote repository now there's
  4894. 3:06:58four major Ops you can do for this we're
  4895. 3:07:00going to only be going through the vs
  4896. 3:07:02code option which I feel is the simplest
  4897. 3:07:05for those that buy the course notes and
  4898. 3:07:07certificate I have detailed instructions
  4899. 3:07:10for the second and third option as well
  4900. 3:07:12if you want to do that all right so
  4901. 3:07:14let's get into creating that repository
  4902. 3:07:15using vs code so inside of here you
  4903. 3:07:18should have navigated or have your
  4904. 3:07:20project open for me the project is SQL
  4905. 3:07:22project data jobs analysis I'm going go
  4906. 3:07:25ahead over to the activity bar and
  4907. 3:07:27select Source control and for this we
  4908. 3:07:31have two different options the first is
  4909. 3:07:34just initialize a repository so
  4910. 3:07:36basically create that local repository
  4911. 3:07:38that dogit folder for you then to have
  4912. 3:07:41locally but this doesn't push to GitHub
  4913. 3:07:44so we actually want to do the second
  4914. 3:07:45option of publish to GitHub as it not
  4915. 3:07:47only initializes a repository locally
  4916. 3:07:50but also it pushes all of your different
  4917. 3:07:53content that you have here to GitHub now
  4918. 3:07:56I've already logged into GitHub so
  4919. 3:07:58whenever you click this button it may
  4920. 3:08:00prompt you to go through the login steps
  4921. 3:08:02to set up your GitHub account to be
  4922. 3:08:05associated with your vs code profile
  4923. 3:08:07right here walk through that process and
  4924. 3:08:09then you'll get to the next step that
  4925. 3:08:10I'm going to be at so I'll click publish
  4926. 3:08:12to GitHub it's going to ask do I want to
  4927. 3:08:14publish to a private repository or a
  4928. 3:08:16public Repository
  4929. 3:08:18I want this to be available for the
  4930. 3:08:19world to see so I'm going to do public
  4931. 3:08:21then it's going to ask me which files
  4932. 3:08:23you should include in this repository
  4933. 3:08:26this is very important that you get this
  4934. 3:08:27step right as I had to repeat this
  4935. 3:08:28earlier I'm going I made a mistake so
  4936. 3:08:31for one we don't care about these dot
  4937. 3:08:34files right here these are hidden files
  4938. 3:08:36that have no effect on showing your work
  4939. 3:08:38so I'm going to go ahead and uncheck
  4940. 3:08:40them additionally these are the other
  4941. 3:08:42folders I have right now I have that SQL
  4942. 3:08:44load that you had that CSV files of all
  4943. 3:08:47the different CSV file data that we
  4944. 3:08:48Import in our database and then I
  4945. 3:08:50created another folder for advaned SQL
  4946. 3:08:52that had all those different problems
  4947. 3:08:53that we work so far in the advance
  4948. 3:08:55section this SQL files folder is
  4949. 3:08:58extremely large and so because of that
  4950. 3:09:01GitHub isn't going to allow you to
  4951. 3:09:03upload all that data to it Additionally
  4952. 3:09:06you don't really need to be keeping all
  4953. 3:09:07that stuff on a GitHub anyway to show
  4954. 3:09:09your work so I'm going to go ahead and
  4955. 3:09:11actually uncheck it so for you you
  4956. 3:09:13should only have one folder and maybe
  4957. 3:09:16two actually created this point that you
  4958. 3:09:19want to leave checked you're going to go
  4959. 3:09:20ahead and click okay it should give you
  4960. 3:09:23this message of successfully published
  4961. 3:09:25this project to GitHub I'm going to go
  4962. 3:09:27ahead and open on GitHub and Bam here we
  4963. 3:09:30have it inside of GitHub we have our
  4964. 3:09:32folder that I have for advanced SQL of
  4965. 3:09:34all our different files that I created
  4966. 3:09:36our SQL load for the files to create our
  4967. 3:09:39database itself and then this dog ignore
  4968. 3:09:43file and I'm going make this a little
  4969. 3:09:44bit bigger if you recall these are the
  4970. 3:09:47same files that we basically unchecked
  4971. 3:09:50from before they were put into thisg
  4972. 3:09:53ignore file hence they're not being
  4973. 3:09:55tracked in git and because they're not
  4974. 3:09:57being tracked in git they're not getting
  4975. 3:09:59uploaded to GitHub so we just did all
  4976. 3:10:01four of the steps necessary to get git
  4977. 3:10:04and GitHub set up for this project and
  4978. 3:10:07just to Showcase this is our project
  4979. 3:10:09that we have right here I'm going to go
  4980. 3:10:11ahead and show our hidden folders that
  4981. 3:10:13we have inside of here such as that get
  4982. 3:10:15ignore and also get so we can actually
  4983. 3:10:18see that we're tracking all the changes
  4984. 3:10:20inside of here don't check don't touch
  4985. 3:10:21any of these files right here but I just
  4986. 3:10:23wanted to Showcase where all these are
  4987. 3:10:25and that they're actually in here in the
  4988. 3:10:26project now when I navigate back into
  4989. 3:10:29VSS code I'm going to see that yes it
  4990. 3:10:31has that new do ignore file then you're
  4991. 3:10:33going to also notice that these two
  4992. 3:10:36folders here are grayed out and that's
  4993. 3:10:39because they're no longer being tracked
  4994. 3:10:41by Source control and because anytime we
  4995. 3:10:44do any changes inside of them they're
  4996. 3:10:45not going to be tracked so they're gray
  4997. 3:10:46it out to let you know so we're going to
  4998. 3:10:48walk through two different ways to
  4999. 3:10:50actually Implement changes inside of
  5000. 3:10:52your working directory and local
  5001. 3:10:54repository and then have it updated
  5002. 3:10:56inside of your remote repository so the
  5003. 3:10:58first thing we're going to be looking at
  5004. 3:10:59are pushing changes and this is
  5005. 3:11:02basically uploading your local content
  5006. 3:11:05that's been adapted or updated and then
  5007. 3:11:08pushing it up to GitHub so I'm going to
  5008. 3:11:10create a folder called project and then
  5009. 3:11:13SQL this is the folder or directory
  5010. 3:11:15we're going to be using to store all the
  5011. 3:11:18different queries that we're going to be
  5012. 3:11:19working on during this project section
  5013. 3:11:22inside of this project SQL I'll go ahead
  5014. 3:11:24and create a file and I'll name this
  5015. 3:11:26we'll keep it simple right now query
  5016. 3:11:291sq now after creating it it should open
  5017. 3:11:32up here on the right and you're going to
  5018. 3:11:33notice that these contents are green and
  5019. 3:11:36if we navigate over to our source
  5020. 3:11:38control tab we can see that it's
  5021. 3:11:41actually tracking that it not only it
  5022. 3:11:43sees that we have created this new
  5023. 3:11:44folder but also this new file anyway I'm
  5024. 3:11:46going to just just come inside of here
  5025. 3:11:48um I'm going to put in a comment delete
  5026. 3:11:51this later and I'm going to save this
  5027. 3:11:54I'm going close out of this file so
  5028. 3:11:56let's go ahead and now push these
  5029. 3:11:58changes so inside of source control I'm
  5030. 3:12:00going to come up here and give this
  5031. 3:12:03commit that we're going to be doing a
  5032. 3:12:05name specifically I'm going to just say
  5033. 3:12:07name this push example because we're
  5034. 3:12:08doing a push example from there we're
  5035. 3:12:10going to go into actually committing it
  5036. 3:12:12so we'll press commit and now these
  5037. 3:12:15changes have been updated inside of our
  5038. 3:12:18local repository and these are stage
  5039. 3:12:21changes if you will so now we want to
  5040. 3:12:23get these changes that are on our local
  5041. 3:12:26repository up to the remote repository
  5042. 3:12:28so we're going to then sync changes so I
  5043. 3:12:30can see that there's nothing here in
  5044. 3:12:31changes staged anymore everything should
  5045. 3:12:34be UPS to date let's go into GitHub and
  5046. 3:12:36see if it was updated so inside of
  5047. 3:12:38GitHub I'm just going to refresh this
  5048. 3:12:39page to see if it has and now we have
  5049. 3:12:42this folder of project SQL which has our
  5050. 3:12:45query inside of it saying like this
  5051. 3:12:47layer so that was example of how we can
  5052. 3:12:50push changes from local repository up to
  5053. 3:12:52our remote repository now let's actually
  5054. 3:12:55look at an example of pulling changes
  5055. 3:12:57we're going to make an alteration on our
  5056. 3:13:00remote repository specifically inside of
  5057. 3:13:02GitHub and then from there pull it onto
  5058. 3:13:05our local machine to be in our local
  5059. 3:13:06repository so you can also make changes
  5060. 3:13:09inside of GitHub itself in this case
  5061. 3:13:12right here it's saying hey you want to
  5062. 3:13:14add a readme and we do want to
  5063. 3:13:15eventually create a readme so we can
  5064. 3:13:17just do it here if we wanted to so I'm
  5065. 3:13:20going to select add a readme and so I'm
  5066. 3:13:23going to put a message in here to update
  5067. 3:13:24the contents of this later and now we're
  5068. 3:13:27going to commit these changes to our
  5069. 3:13:29remote repository we have our commit
  5070. 3:13:31message right here of creating a read me
  5071. 3:13:33then you should have your email that
  5072. 3:13:35you're using for this when to commit it
  5073. 3:13:36directly to the main branch so I'll
  5074. 3:13:38commit changes all right so now we have
  5075. 3:13:41this read me here inside of here and I
  5076. 3:13:43can see the read me down at the bottom D
  5077. 3:13:45update contents to this later now back
  5078. 3:13:47on my local machine inside of vs code
  5079. 3:13:51this file is not there that's because we
  5080. 3:13:53haven't done a pull yet to get that
  5081. 3:13:56information or get that new file here so
  5082. 3:13:58we can do that by going over to Source
  5083. 3:14:01control and then selecting these three
  5084. 3:14:03ellipses right here and then going under
  5085. 3:14:05pull push and specifically selecting
  5086. 3:14:07pull now when I navigate over to the
  5087. 3:14:10explore menu we now have this read me
  5088. 3:14:13file right here which the two do update
  5089. 3:14:16content toist layer all right so now we
  5090. 3:14:18have our repository all set up not only
  5091. 3:14:20locally but also remotely and we're now
  5092. 3:14:23ready to go ahead forward with actually
  5093. 3:14:25doing our queries and getting everything
  5094. 3:14:27done for building our project now at
  5095. 3:14:29this point you know everything that you
  5096. 3:14:30need to know for git however you'd like
  5097. 3:14:33to learn more I have this video right
  5098. 3:14:35here where I go into further detail on
  5099. 3:14:38how I use git as a data analyst and
  5100. 3:14:41break it down even further so feel free
  5101. 3:14:43to check that video out I'll link it
  5102. 3:14:45with all the other resources I'll be
  5103. 3:14:46providing for this course all right with
  5104. 3:14:48that I'll see you in the next one where
  5105. 3:14:49we jumping into the
  5106. 3:14:54queries all right so let's move into
  5107. 3:14:56that first question that we're going to
  5108. 3:14:58be solving using a SQL query in order to
  5109. 3:15:01understand what are the top paying jobs
  5110. 3:15:03for my role in my case I'm a using data
  5111. 3:15:05analyst as a reminder we're going to be
  5112. 3:15:06walking through five separate questions
  5113. 3:15:08and these all really build on each other
  5114. 3:15:11so we're going be gaining insights from
  5115. 3:15:13each and then by the end we're going to
  5116. 3:15:15have a more holistic picture of what
  5117. 3:15:17roles and what skills we should be
  5118. 3:15:19targeting so if you haven't done so
  5119. 3:15:21already create that folder where we
  5120. 3:15:23putting all this I created this one
  5121. 3:15:25called projector SQL and then from there
  5122. 3:15:28start a new file I named this one query
  5123. 3:15:311 initially I'm going to actually go in
  5124. 3:15:33and rename it specifically I'm going to
  5125. 3:15:35give it that one to make sure it's up at
  5126. 3:15:37the top whenever we actually save these
  5127. 3:15:38files sequentially and then also name it
  5128. 3:15:41top paying jobs cuz that's what we're
  5129. 3:15:42trying to solve so at the top of my file
  5130. 3:15:45I'm going ahead and put what question
  5131. 3:15:47we're going to be solving and then also
  5132. 3:15:49breaking it down into what are some
  5133. 3:15:52deliverables I want from this so the
  5134. 3:15:54deliverables are I want to identify the
  5135. 3:15:56top 10 highest paying data analyst roles
  5136. 3:15:59that are available remotely on top of
  5137. 3:16:02this I want to focus on job postings
  5138. 3:16:04with a salary so I want to remove
  5139. 3:16:06anything that doesn't include a salary
  5140. 3:16:08because obviously we don't know if it's
  5141. 3:16:09top paying or not and finally I just put
  5142. 3:16:11in there why we're doing this overall
  5143. 3:16:13it's going to offer insights into our
  5144. 3:16:15final problem question and answer we're
  5145. 3:16:18going to get into of finding the most
  5146. 3:16:20optimal skills and most optimal roles to
  5147. 3:16:22be pursuing as a data analyst so let's
  5148. 3:16:25start building our base query and we're
  5149. 3:16:28going to start with these six columns
  5150. 3:16:30first they target things like the job ID
  5151. 3:16:33the title location what type of job job
  5152. 3:16:36it is whether it's contract or whether
  5153. 3:16:38it's full-time the salary what we hear
  5154. 3:16:41about and then actually a job posting
  5155. 3:16:43date additionally we want to do this
  5156. 3:16:45from the most important table that we've
  5157. 3:16:47been doing is that job posting fact
  5158. 3:16:49table to make sure that we did this
  5159. 3:16:51right as always as we're inating along
  5160. 3:16:53I'll be running these queries to see
  5161. 3:16:55that they're running correctly so
  5162. 3:16:56pressing command D command D and then
  5163. 3:16:59selecting what actual database you're
  5164. 3:17:01going to be using for this if you have
  5165. 3:17:02to uh navigate out of this I'm going to
  5166. 3:17:04go through and set it back
  5167. 3:17:07up and boom we're getting these results
  5168. 3:17:09for the different job tiles job
  5169. 3:17:11locations job schedule type job posted
  5170. 3:17:13date okay this looking good so moving
  5171. 3:17:16into that first bullet point we want to
  5172. 3:17:18identify data analyst roles and those
  5173. 3:17:21that are available remotely so for this
  5174. 3:17:24we'll be using a where keyword and the
  5175. 3:17:26first thing I'm going to specify is job
  5176. 3:17:27title short equal to data analyst and
  5177. 3:17:30then we want to do an and statement
  5178. 3:17:32because we also want to get those that
  5179. 3:17:33are available remotely so we have to
  5180. 3:17:35specify a location so for location we'll
  5181. 3:17:38specify it as anywhere so going to go
  5182. 3:17:41ahead and run this Now command D command
  5183. 3:17:43D and boom looks like we're getting all
  5184. 3:17:45these data analysts r rolls anywhere and
  5185. 3:17:48then oh we're getting a lot of null
  5186. 3:17:49values for that salary year average
  5187. 3:17:52column so that's probably what we're
  5188. 3:17:53going to want to tackle next which is
  5189. 3:17:56conveniently our second bullet point
  5190. 3:17:57that we need to do we need to remove all
  5191. 3:17:58those null values so we're going to do
  5192. 3:18:00this add to this sare statement more by
  5193. 3:18:02adding an and statement and then adding
  5194. 3:18:04that salary year average equal to or
  5195. 3:18:08sorry is not null so let's try this
  5196. 3:18:12again command D make sure that we're
  5197. 3:18:13working and yep we removed all those
  5198. 3:18:16null values all right so the last things
  5199. 3:18:18for this are we need to one we want to
  5200. 3:18:21get the top 10 so how do we do that well
  5201. 3:18:24first we know we want to do a limit
  5202. 3:18:26statement we're going to limit it to the
  5203. 3:18:28top 10 and the other thing is we
  5204. 3:18:31actually need an order buy and for this
  5205. 3:18:34we'll do the salary year average column
  5206. 3:18:37again and remember this is initially or
  5207. 3:18:40by default it's going to do ascending so
  5208. 3:18:41we want to do descending running this
  5209. 3:18:44query we're getting all the different
  5210. 3:18:46job
  5211. 3:18:47and then they're going from high to low
  5212. 3:18:49and if you remember craw from earlier we
  5213. 3:18:52had one that was around 650,000 and that
  5214. 3:18:55was here now I'm noticing with this I
  5215. 3:18:57actually I want to know one other thing
  5216. 3:19:01uh with this and that's company because
  5217. 3:19:02this is really great that it tells us
  5218. 3:19:04these type of roles but I'm actually
  5219. 3:19:06curious that not just these are remote
  5220. 3:19:08and it looks like that most of these are
  5221. 3:19:09all full-time but also what company so
  5222. 3:19:12we're going to take this one a little
  5223. 3:19:13bit of a step further I'm going go ahead
  5224. 3:19:15and close this out I'm going to add
  5225. 3:19:17after that from statement I'm going to
  5226. 3:19:19add a left join and I'm going to specify
  5227. 3:19:22that we want to connect this to that
  5228. 3:19:24company dim table that has the company
  5229. 3:19:26name so and both of these are connected
  5230. 3:19:30on that Company ID column so I list the
  5231. 3:19:33the table name in front of the column
  5232. 3:19:35for both of these and then set them
  5233. 3:19:37equal to each other to get that left
  5234. 3:19:38join so now I can come in include a
  5235. 3:19:40comma that column of the company name is
  5236. 3:19:43name and we'll actually give it an alias
  5237. 3:19:45uh to make sure it's not
  5238. 3:19:47sort of like confusing of company name
  5239. 3:19:49okay let's go ahead and run this bad boy
  5240. 3:19:53and moving this over here so we can see
  5241. 3:19:55it a little better we have all the
  5242. 3:19:57different things oh and now we get to
  5243. 3:19:59see the different companies and so we
  5244. 3:20:02have things like meta so like a tech
  5245. 3:20:04company AT&T also kind of a tech company
  5246. 3:20:07Pinterest a tech company it looks like
  5247. 3:20:09some other Healthcare type companies all
  5248. 3:20:12right so this is a great start to our
  5249. 3:20:14first problem we've identified the
  5250. 3:20:16different jobs that we have and we've
  5251. 3:20:17also been able to see what could we
  5252. 3:20:19expect at some of the top paying roles
  5253. 3:20:22so now I have a good frame of mind of
  5254. 3:20:23what we should be targeting for and when
  5255. 3:20:25you're working through this Feel Free as
  5256. 3:20:26I mentioned before to modify this to
  5257. 3:20:29your need whether you don't have to do
  5258. 3:20:30data analyst you can do something data
  5259. 3:20:32scientist data engineers and you can
  5260. 3:20:33change up to that job location to where
  5261. 3:20:35you are as we have locations from around
  5262. 3:20:37the world inside of this data set all
  5263. 3:20:40right for that see you in the next one
  5264. 3:20:47all right so let's get into the second
  5265. 3:20:49query that we're going to be focusing on
  5266. 3:20:51and it's going to really be building a
  5267. 3:20:53lot on the previous query that we just
  5268. 3:20:56did in analyzing the top paying jobs for
  5269. 3:20:59a data analyst specifically here's the
  5270. 3:21:02results of that query again and I feel
  5271. 3:21:05like it's still lacking I know I added
  5272. 3:21:07that company name into it to dive into
  5273. 3:21:09it deeper but I don't feel like that
  5274. 3:21:12really answers the question that I'm
  5275. 3:21:13truly trying to find out of what skills
  5276. 3:21:15are also inil important so that's what
  5277. 3:21:18we're going to be doing with this diving
  5278. 3:21:19in to find out what are the top skills
  5279. 3:21:22inside of each of these roles that are
  5280. 3:21:24the main drivers behind why this salary
  5281. 3:21:27yearly average value is so high since
  5282. 3:21:30we're going to be building on this
  5283. 3:21:31further I'm going to go ahead and copy
  5284. 3:21:34this query on over into our new SQL file
  5285. 3:21:38that're going to doing for this and I'm
  5286. 3:21:39going to create a new file started with
  5287. 3:21:42two and I'm going to name it top paying
  5288. 3:21:44job skills and also make get a SQL file
  5289. 3:21:47press enter and then I'm going to
  5290. 3:21:49actually go ahead and paste that query
  5291. 3:21:51in and additionally I added in what
  5292. 3:21:54question we're going to be answering
  5293. 3:21:55this which are around what skills
  5294. 3:21:56required for the top hang roles we need
  5295. 3:21:59to be really doing two main things one
  5296. 3:22:02using that top 10 highest paying roles
  5297. 3:22:05that we identified previously query and
  5298. 3:22:07somehow combine it in and join it with
  5299. 3:22:10all of our skills now this because we've
  5300. 3:22:13previously built a query this is a
  5301. 3:22:15perfect opportunity for something
  5302. 3:22:16something like a subquery or CTE since
  5303. 3:22:19this is a little bit more complex we're
  5304. 3:22:21going to be going with a CTE for this
  5305. 3:22:23once again let's make sure that this
  5306. 3:22:24query Works while running it I'm going
  5307. 3:22:27to move it over here and we can see from
  5308. 3:22:29this there's a few columns we can
  5309. 3:22:31actually remove from this specifically I
  5310. 3:22:33don't really care about that job
  5311. 3:22:34location or job schedule type and the
  5312. 3:22:38job post to date isn't really providing
  5313. 3:22:39much value either I'm going to go ahead
  5314. 3:22:42and clean that up and move those out of
  5315. 3:22:45here so let's start by making this into
  5316. 3:22:47a CTE we do that with that with keyword
  5317. 3:22:51and we'll specify this as the top paying
  5318. 3:22:54jobs result set and we'll put the
  5319. 3:22:56parentheses to enclose all of this in
  5320. 3:22:59I'm actually going to select it all tab
  5321. 3:23:01it over to make it have a nice little
  5322. 3:23:04formatting and then put some closing
  5323. 3:23:06parentheses right there make sure the CT
  5324. 3:23:09is working properly I'm going to just go
  5325. 3:23:11ahead and do a select all from this
  5326. 3:23:14topang jobs query right here or top
  5327. 3:23:17paying jobs result set and I'm going to
  5328. 3:23:20go ahead and run it to make sure that
  5329. 3:23:21it's running properly and looks like
  5330. 3:23:23it's good if you're call from our
  5331. 3:23:25diagram of the actual database itself
  5332. 3:23:28we're going to need to connect two
  5333. 3:23:30tables of this so not only the skills
  5334. 3:23:32job dim table but also the skills dim
  5335. 3:23:35because that's actually what's going to
  5336. 3:23:36have the names inside of it but what
  5337. 3:23:38join method are we going to be using to
  5338. 3:23:41join this to our job postings fact table
  5339. 3:23:44well remember from a join section there
  5340. 3:23:46there's typically only two joins that
  5341. 3:23:48we're going to do it's going to be a
  5342. 3:23:49left join or an inner join now in this
  5343. 3:23:52case that a table is going to be our job
  5344. 3:23:54postings fact table and we really only
  5345. 3:23:57care about skills associated with a
  5346. 3:24:01salary so if there's a job that doesn't
  5347. 3:24:04have any skills we don't really care
  5348. 3:24:07about that too much so left join is not
  5349. 3:24:09going to be applicable in this case
  5350. 3:24:11instead we're going to be going with
  5351. 3:24:12inner join so I'm going to start with an
  5352. 3:24:14inner join on the skills job dim
  5353. 3:24:17specifying for this one we want to
  5354. 3:24:19connect the job ID from our top paying
  5355. 3:24:21jobs result set with the skills job dim
  5356. 3:24:24job ID additionally we want to do an in
  5357. 3:24:27join on our skills dim table connecting
  5358. 3:24:29both of these on their skill ID column
  5359. 3:24:32now right now I have a select star for
  5360. 3:24:35all the different columns we're just
  5361. 3:24:36going to go ahead and run this to make
  5362. 3:24:37sure that it works pressing command D
  5363. 3:24:40command D and then moving this over here
  5364. 3:24:43looks like we were able to join this all
  5365. 3:24:45on but we have a a few columns in here
  5366. 3:24:47that we don't really care about so we're
  5367. 3:24:48going to remove those so first for that
  5368. 3:24:51top paying jobs result set that we have
  5369. 3:24:53here I want all of the columns from that
  5370. 3:24:56and I could go ahead and write out all
  5371. 3:24:57of these columns but instead I'm just
  5372. 3:25:00going to do this of dot top paying jobs
  5373. 3:25:03and then do a DOT and Then star and this
  5374. 3:25:05is going to select all the columns from
  5375. 3:25:07that table additionally I want the
  5376. 3:25:10skills from this skills dim table okay
  5377. 3:25:14let's go ahead and run this
  5378. 3:25:17all right so it looks like the quer is
  5379. 3:25:18working I do want to do one last thing
  5380. 3:25:21before we dive in and that's make sure
  5381. 3:25:22that we actually organize this by the
  5382. 3:25:24salary so I'm going to start looking at
  5383. 3:25:26those first so we're going to put a last
  5384. 3:25:29statement of order by and specify that
  5385. 3:25:33we're going to do this for salary year
  5386. 3:25:35and the same thing putting in in that
  5387. 3:25:36descending order this order buy may or
  5388. 3:25:39may not be necessary depending on how it
  5389. 3:25:41queries it may come already in an
  5390. 3:25:44ordered fashion but you should just do
  5391. 3:25:46this for best practices in case that
  5392. 3:25:49this does happen to you and you want to
  5393. 3:25:50get in the order and it doesn't anyway
  5394. 3:25:51let's select all this and actually run
  5395. 3:25:53this query and start analyzing it all
  5396. 3:25:57right so this is pretty interesting I
  5397. 3:25:58took a peek through all these different
  5398. 3:26:00jobs and the skills that are requiring
  5399. 3:26:03now overall there's a lot of postings
  5400. 3:26:05and we're going to actually use some
  5401. 3:26:06other tools to analyze this real quick
  5402. 3:26:07but from what I'm seeing actually
  5403. 3:26:09looking at it there's a very much a
  5404. 3:26:11commonality of seeing SQL and python in
  5405. 3:26:15almost every single one of these rules
  5406. 3:26:18but with all these results with how much
  5407. 3:26:19it is you'd really be better off using
  5408. 3:26:22it in your analytical tool of choice
  5409. 3:26:24could be something like Excel python
  5410. 3:26:26whatever and you could do this by
  5411. 3:26:28extracting this data out by Saving
  5412. 3:26:31results and you can save the results as
  5413. 3:26:32a CSV so I'm saving it inside my desktop
  5414. 3:26:35and exporting it out anyway this portion
  5415. 3:26:37is not required but I went ahead and
  5416. 3:26:39gave chbt this CSV and told it these are
  5417. 3:26:43the top 10 diis roles I found in job
  5418. 3:26:46postings in 2023 can you analyze the
  5419. 3:26:48skill column and display the insights
  5420. 3:26:51and after I used some python code to go
  5421. 3:26:52in and actually analyze it it found that
  5422. 3:26:54that sqls leading and eight of the
  5423. 3:26:57different roles python is in seven and
  5424. 3:26:59Tableau is in six he even went a step
  5425. 3:27:01further and had it make this
  5426. 3:27:03visualization which shows a lot better
  5427. 3:27:06visually what is going on here with all
  5428. 3:27:09this data that we just collected anyway
  5429. 3:27:11I'm going to go ahead and copy this
  5430. 3:27:12Insight right here on the skill
  5431. 3:27:15breakdown for that
  5432. 3:27:16and actually go in and paste it down
  5433. 3:27:19here
  5434. 3:27:20underneath our query that we did
  5435. 3:27:23additionally if we want to use these
  5436. 3:27:25results later I'm going to go ahead also
  5437. 3:27:27and click this icon here to open the
  5438. 3:27:29results as a Json file I'm going select
  5439. 3:27:32all of this by pressing command a and
  5440. 3:27:34then coming underneath here making sure
  5441. 3:27:36I'm inside that comment right there
  5442. 3:27:37actually pasting all these different
  5443. 3:27:39results so if we wanted to we can go
  5444. 3:27:41back later and verify what results I had
  5445. 3:27:43from this query anyway just be clear
  5446. 3:27:46this chat gbt portion completely
  5447. 3:27:48optional I just wanted to dive into it
  5448. 3:27:50further and pasting the results
  5449. 3:27:51completely optional the main portion is
  5450. 3:27:53we wanted to make sure that we have this
  5451. 3:27:55query right here as this was solving
  5452. 3:27:58what we were trying to find all right
  5453. 3:28:00now it's your turn to give it a try I'm
  5454. 3:28:01curious to see from your perspective
  5455. 3:28:03especially if you're using something
  5456. 3:28:04different from data analyst or a remote
  5457. 3:28:06location how those skills are different
  5458. 3:28:09well with that see you in the next one
  5459. 3:28:16all right in this portion we're going to
  5460. 3:28:17be diving into what are the most in
  5461. 3:28:19demand skills particularly for me I'm be
  5462. 3:28:22looking at data analyst now if we look
  5463. 3:28:24back to what question are be doing for
  5464. 3:28:26this we've already answered the first
  5465. 3:28:28two already we're now on to the third
  5466. 3:28:30and this one actually we answered
  5467. 3:28:33previously and well you can actually go
  5468. 3:28:36ahead and use those results previously
  5469. 3:28:38or I'm going to actually work at a
  5470. 3:28:40different method specifically in problem
  5471. 3:28:43number seven we found the count of the
  5472. 3:28:45number number of remote job postings per
  5473. 3:28:47skill and whenever you run this query
  5474. 3:28:50command e command e we found that for
  5475. 3:28:53data analyst and also for work for home
  5476. 3:28:55these were the top skills with surprise
  5477. 3:28:57surprise SQL and also python topping
  5478. 3:29:00this list anyway if you have these query
  5479. 3:29:03results saved you can go ahead probably
  5480. 3:29:05just copy and paste this then move on to
  5481. 3:29:07this next section of query 4 but I'm
  5482. 3:29:09going to go ahead now and work this
  5483. 3:29:11problem slightly different is this one
  5484. 3:29:14right here how we have a written is a
  5485. 3:29:17little bit longer than I'd like it for a
  5486. 3:29:19query to be I want it to be short and
  5487. 3:29:20simple as possible because we get into
  5488. 3:29:22bigger data sets it's going to take more
  5489. 3:29:25time to run these type so let's try to
  5490. 3:29:27rewrite this so I'm going to start by
  5491. 3:29:29creating a new file I'm going to name it
  5492. 3:29:31top demanded skills and dsql all right
  5493. 3:29:34so for this one we're going to be
  5494. 3:29:35focusing on what are the most in demand
  5495. 3:29:37skills and to do this we only have a few
  5496. 3:29:40steps for this we're going to be joining
  5497. 3:29:41our job posting tables to our skill
  5498. 3:29:44tables like we previously did we're
  5499. 3:29:46going to reuse some code from that one
  5500. 3:29:48and then from there we're going to limit
  5501. 3:29:49it down to those top five skills and for
  5502. 3:29:51this one I want to focus on all job
  5503. 3:29:54postings not just those remote ones
  5504. 3:29:56really just see if there's any
  5505. 3:29:57difference anyway I'm going to go ahead
  5506. 3:29:59and open up that last one that we did
  5507. 3:30:01previously and I'm going to go ahead and
  5508. 3:30:03copy this on over and then mainly
  5509. 3:30:07pasting in that inner join this is
  5510. 3:30:11really a lot to type in so I'm going to
  5511. 3:30:13I'm going to just streamline this a
  5512. 3:30:14little bit so we'll do it a simple
  5513. 3:30:16select star just to start out from this
  5514. 3:30:19and we'll do from the job postings fact
  5515. 3:30:23table and we're going to be doing once
  5516. 3:30:24again that injin to that skills table to
  5517. 3:30:27the skills job dim table and then
  5518. 3:30:29finally to the skills dim table let's
  5519. 3:30:30just go ahead and run this and see if
  5520. 3:30:32this actually works and I already made
  5521. 3:30:35my first there as I didn't rename the
  5522. 3:30:38table right here it I still had top
  5523. 3:30:40paying jobs uh for that result set
  5524. 3:30:43anyway let's actually try to run this
  5525. 3:30:44again hopefully it works
  5526. 3:30:46all right this is running for a little
  5527. 3:30:48bit too long of a time and I understand
  5528. 3:30:50that cuz we're combining all these
  5529. 3:30:51different tables together we're going to
  5530. 3:30:53be limiting anyway these uh to find the
  5531. 3:30:56top five jobs anyway so I'm going to go
  5532. 3:30:58ahead and just throw this limit five
  5533. 3:30:59statement here to speed up this query I
  5534. 3:31:02was waiting about a minute and it wasn't
  5535. 3:31:04uh loading all right lot quicker
  5536. 3:31:06whenever I do that limit five in there
  5537. 3:31:08don't do what I just did there and it
  5538. 3:31:10looks like it's combining all these
  5539. 3:31:11different tables I can scroll the way to
  5540. 3:31:12end and see that the skills got combined
  5541. 3:31:14into this so remember what we're trying
  5542. 3:31:16to do we're trying to find what are the
  5543. 3:31:18most in demand skills basically we're
  5544. 3:31:21going to find a aggregation of the sum
  5545. 3:31:24of skills so we're going to need to
  5546. 3:31:26provide a count in order to find out how
  5547. 3:31:29many SQL entries are how many python
  5548. 3:31:31Excel and so on so first thing I'm going
  5549. 3:31:33to specify is that skills column because
  5550. 3:31:36I want to return that and then we're
  5551. 3:31:38going to do that aggregation method
  5552. 3:31:39we're going to be doing a count for this
  5553. 3:31:42let's use the job ID for this and I'll
  5554. 3:31:45just put in sales job dim. job ID and
  5555. 3:31:48we'll put this as the demand count now
  5556. 3:31:52remember anytime we do some sort of
  5557. 3:31:54aggregation we have to do a group buy so
  5558. 3:31:57for this we'll do the group buy and we
  5559. 3:31:59obviously want to group buy the skills
  5560. 3:32:01let's go ahead and run this to see where
  5561. 3:32:03we're at right this make sure it's
  5562. 3:32:04running properly okay this is looks like
  5563. 3:32:07it's tabulating right now right now
  5564. 3:32:09we're not having any type of sorting so
  5565. 3:32:11that's what we're going to need to fix
  5566. 3:32:12next but we can at least see that we're
  5567. 3:32:13getting those demand counts of those
  5568. 3:32:15different skills looks like they're
  5569. 3:32:17actually doing this in alphabetical
  5570. 3:32:18order so let's go ahead and put that
  5571. 3:32:20order by in there now so order by and
  5572. 3:32:24we're going to order it by the demand
  5573. 3:32:27count run this again command e command
  5574. 3:32:30e and obviously we got to do it
  5575. 3:32:33descending run this again all right so
  5576. 3:32:35now we're getting all the skills right
  5577. 3:32:37now and it looks like sequels topping
  5578. 3:32:39the list at around 380,000 python very
  5579. 3:32:42close by now remember if we go back to
  5580. 3:32:45our original question we want to find
  5581. 3:32:46out what are the most in demand skills
  5582. 3:32:48for data analyst so we need to modify
  5583. 3:32:51this and insert in a we statement to
  5584. 3:32:54filter by this so let's use that weer
  5585. 3:32:56keyword to filter this by we're going to
  5586. 3:32:58be using that job title short column and
  5587. 3:33:02then specifying that we want to filter
  5588. 3:33:03it by data analyst so selecting it all
  5589. 3:33:07and running it command e command e boom
  5590. 3:33:10now we got it and it looks like we have
  5591. 3:33:13SQL Excel python tableau and powerbi
  5592. 3:33:16Topping the list now I am curious to see
  5593. 3:33:19how it compares to if it was only remote
  5594. 3:33:22jobs so I'm going to add I'm take this a
  5595. 3:33:24little bit step further just to compare
  5596. 3:33:25it I'm going to add the and statement
  5597. 3:33:27for the wear specify job work from home
  5598. 3:33:30as true ring this command e command e we
  5599. 3:33:34can see when we compare these we still
  5600. 3:33:36have so on the left hand side we have
  5601. 3:33:38those that table that is not uh that is
  5602. 3:33:41that allows any type of work whereas the
  5603. 3:33:44one on the right is only allowing remote
  5604. 3:33:46work or work from home and the general
  5605. 3:33:49trend is the same with SQL Excel python
  5606. 3:33:52Tableau powerbi and it looks like it's
  5607. 3:33:54very much in the same proportion so
  5608. 3:33:56there's not a lot of difference between
  5609. 3:33:57the two all right now it's your turn to
  5610. 3:33:59give it a try feel free to once again
  5611. 3:34:01modify this for your specific role but
  5612. 3:34:03also you don't have to stick to this
  5613. 3:34:05thing where I just did remote you can do
  5614. 3:34:07your specific location or really
  5615. 3:34:09anything particular to you that you want
  5616. 3:34:11to filter down further on with that see
  5617. 3:34:13you in the next one
  5618. 3:34:19all right so let's get into the second
  5619. 3:34:20last skill of analyzing what are the top
  5620. 3:34:24skills based on salary now this is all
  5621. 3:34:27in progression to learning what is the
  5622. 3:34:29most optimal skill if you recall earlier
  5623. 3:34:32we've already analyzed to find what were
  5624. 3:34:34the most highest paying jobs with one at
  5625. 3:34:36around 650,000 for all those high paying
  5626. 3:34:39jobs that we found we then dived into
  5627. 3:34:41the skills themselves and we found
  5628. 3:34:43popular tools like SQL and python are
  5629. 3:34:46common in a lot of these rules and so we
  5630. 3:34:48dived in further to look at how popular
  5631. 3:34:50they were not just among the top paying
  5632. 3:34:52jobs but also all jobs and there was
  5633. 3:34:55still a similar trend of that SQL and
  5634. 3:34:57Python and even things like Excel
  5635. 3:34:58Tableau and powerbi for data analyst so
  5636. 3:35:01our ultimate goal which will be in the
  5637. 3:35:03next query of what is the most optimal
  5638. 3:35:04skill looking at what is not only high
  5639. 3:35:07paying but also highly in demand we need
  5640. 3:35:10to actually answer that question of what
  5641. 3:35:12is a high-paying skill so for this query
  5642. 3:35:15we're going to be looking at what is the
  5643. 3:35:18average salary associated with a skill
  5644. 3:35:22specifically fine tuning this for me for
  5645. 3:35:24data analyst positions and we want to
  5646. 3:35:27make sure this data actually does
  5647. 3:35:28include salary data we're going to
  5648. 3:35:29exclude any null values and then finally
  5649. 3:35:32we're going to do this initially
  5650. 3:35:34regardless of any location but then I'm
  5651. 3:35:35also going to modify it to me for my
  5652. 3:35:38remote case where I want to look for
  5653. 3:35:39remote jobs and what would I expect it
  5654. 3:35:41to be so back at vs code we're going to
  5655. 3:35:43start with a new blank SQL document that
  5656. 3:35:45we we working from and have the problem
  5657. 3:35:47outlined up at the top so where are we
  5658. 3:35:50going to start with this one so this
  5659. 3:35:51one's very similar to the last query in
  5660. 3:35:54fact because we need the names of the
  5661. 3:35:56skills from that skills dim table and
  5662. 3:35:59also we need the salary data from the
  5663. 3:36:02job postings fact table and previously
  5664. 3:36:05we did a count of values of this column
  5665. 3:36:08but now we just need to do an
  5666. 3:36:09aggregation method basically doing the
  5667. 3:36:11average of these average salaries so
  5668. 3:36:14navigating back to our third query that
  5669. 3:36:17we did I'm actually go ahead and copy
  5670. 3:36:20all of this as a lot of this is going to
  5671. 3:36:21be reusable and paste that in right here
  5672. 3:36:24so if you remember from this one we were
  5673. 3:36:26doing the count of the skills I'm going
  5674. 3:36:28to go ahead and actually just execute it
  5675. 3:36:30to show this was doing account of the
  5676. 3:36:32skills basically we want a very similar
  5677. 3:36:34thing but we want the average salary
  5678. 3:36:36right here so for the time being I'm
  5679. 3:36:38going to remove this and we have the
  5680. 3:36:41from job postings fact our in Joins
  5681. 3:36:44where data analyst is true remember
  5682. 3:36:46we're going to maintain this to look
  5683. 3:36:48regardless location so I'm just going to
  5684. 3:36:50put a comment in here right now and move
  5685. 3:36:52this and right before this so we'll just
  5686. 3:36:54move it out of the way for right now but
  5687. 3:36:56we can put it back whenever we want to
  5688. 3:36:58analyze it for emote jobs from there we
  5689. 3:37:00have group by skills and then an order
  5690. 3:37:02bu we'll have to actually update this as
  5691. 3:37:04well um I'm going to actually change
  5692. 3:37:07this limit to a little bit heftier value
  5693. 3:37:10of just 25 so like I said the lot of
  5694. 3:37:12this core query is already good enough
  5695. 3:37:15and you could feel free to start over
  5696. 3:37:17again with it but I really don't like to
  5697. 3:37:19repeat myself so the first thing I'm
  5698. 3:37:21going to do with modifying this query is
  5699. 3:37:22previously we had the count up here I'm
  5700. 3:37:24going to add in an average function to
  5701. 3:37:27actually average that salary and I'll
  5702. 3:37:29specify the column of salary year
  5703. 3:37:32average now because we have an
  5704. 3:37:33aggregation as always we need to group
  5705. 3:37:36by the appropriate thing in this case we
  5706. 3:37:38do want to group by the skills so we'll
  5707. 3:37:40keep this as is and remember from our
  5708. 3:37:42core things we want to focus on roles
  5709. 3:37:44with specified salary so I'm going to
  5710. 3:37:46add an and keyword right here and then
  5711. 3:37:48for this I'm going to remove any null
  5712. 3:37:51values that are in that salary column
  5713. 3:37:54and also help speed up this query a lot
  5714. 3:37:56faster so I specify salary year average
  5715. 3:37:59is not null and the last thing to do is
  5716. 3:38:01we have this order bu here that needs to
  5717. 3:38:03be filled in so I'm going to go ahead
  5718. 3:38:05and just put this well we need to assign
  5719. 3:38:07an alias for this so I'm going to do an
  5720. 3:38:10as and name this average salary pretty
  5721. 3:38:14original and then whenever we go down
  5722. 3:38:16here to the order by we'll order it by
  5723. 3:38:19that average salary okay let's actually
  5724. 3:38:22run this and see if it works fingers
  5725. 3:38:24cross oh and it works okay and okay like
  5726. 3:38:28usual I messed up and uh the order by I
  5727. 3:38:31did it in ascending because I did the
  5728. 3:38:33default but we at least have all the
  5729. 3:38:35values here okay and it looks like it's
  5730. 3:38:38working correctly also I'm noticing
  5731. 3:38:41these decimal places I don't really
  5732. 3:38:43there's a little bit too much data for
  5733. 3:38:45for me so first thing to fix the order
  5734. 3:38:47bu I'm going to change this to
  5735. 3:38:49descending run this
  5736. 3:38:52again and then let's clean up this
  5737. 3:38:54salary so there's a function we didn't
  5738. 3:38:55talk about yet and that is the round
  5739. 3:38:59function and we can put that outside
  5740. 3:39:01that average function and with round we
  5741. 3:39:04need to actually specify not only the
  5742. 3:39:07column or the aggregation of interest
  5743. 3:39:09but then also after this we have to use
  5744. 3:39:11a comma and we have to specify the
  5745. 3:39:13amount of digits want to round to I
  5746. 3:39:17don't really care about any of these
  5747. 3:39:19digits um so I'm just going to make this
  5748. 3:39:22zero you could make it two for like two
  5749. 3:39:24c uh for um down to the 100th place
  5750. 3:39:27anyway let's go ahead and run this make
  5751. 3:39:29sure this works okay we have all our
  5752. 3:39:32values now all right so this is the top
  5753. 3:39:3425 and looking through it unfortunately
  5754. 3:39:37Python and SQL aren't topping the list
  5755. 3:39:40but it looks like it's more focused
  5756. 3:39:43specifically for data analyst on web
  5757. 3:39:46development tools so like things like
  5758. 3:39:49terraform um and then more Niche tools
  5759. 3:39:52like data robot so this does make sense
  5760. 3:39:56anyway just out of curiosity I want to
  5761. 3:39:57see how this Compares I'm going to close
  5762. 3:39:59out these other windows I want to see
  5763. 3:40:01how this Compares for remote work and
  5764. 3:40:05I'm going to remove this comment right
  5765. 3:40:07here and then run this section
  5766. 3:40:10again and looking at this for remote
  5767. 3:40:13jobs there's a lot more familiar names
  5768. 3:40:15that I'm seeing on here such is Jupiter
  5769. 3:40:17that's like a notebook where you can run
  5770. 3:40:19Python and probably the most surprising
  5771. 3:40:22of all or coolest of all is postgress at
  5772. 3:40:24least made the top 25 anyway similar to
  5773. 3:40:26what we did in query 2 because this is a
  5774. 3:40:28lot of text Data here a lot of analysis
  5775. 3:40:31of what is actually going on or what all
  5776. 3:40:34these different tools are used for I
  5777. 3:40:36actually went up here and select this
  5778. 3:40:38floppy disc right here and had copy
  5779. 3:40:40results as Json to clipboard and I've
  5780. 3:40:43been having an ongoing conversation with
  5781. 3:40:45gbt got a lot of the results from this
  5782. 3:40:47and I just said hey here are the top
  5783. 3:40:48paying skills for D analyst the top 25
  5784. 3:40:51can you provide some quick insights into
  5785. 3:40:52some Trends into these top paying jobs
  5786. 3:40:54and then providing all this Json value
  5787. 3:40:56anyway it provided three insights into
  5788. 3:40:59what are these top paying roles
  5789. 3:41:01consisting of for data analyst
  5790. 3:41:03specifically big data and ml skills are
  5791. 3:41:06a high priority next up comes software
  5792. 3:41:08development and deployment and then
  5793. 3:41:10finally cloud computing so a lot of
  5794. 3:41:13specialized skills that require not only
  5795. 3:41:16SQL but also python anyway I went ahead
  5796. 3:41:18and copi and pasted this into underneath
  5797. 3:41:21this query to basically break down what
  5798. 3:41:23we found out in this query all right
  5799. 3:41:25next one we're going to be diving into
  5800. 3:41:27what is the most optimal skill so you
  5801. 3:41:29haven't done this one already do it for
  5802. 3:41:30you make sure you're adapting it to your
  5803. 3:41:32need and then we'll be diving into the
  5804. 3:41:34final query which I'm super excited to
  5805. 3:41:36get into all right see you in the next
  5806. 3:41:42one all right finally moving into what
  5807. 3:41:44is the most optimal skill I should be
  5808. 3:41:47focusing on as a data analyst or remote
  5809. 3:41:50jobs now if you recall from our third
  5810. 3:41:52query we found out what is the demand
  5811. 3:41:55for certain skills granted we only
  5812. 3:41:57limited to Five results shown but
  5813. 3:41:59basically we can get all the different
  5814. 3:42:00results or the demands for the skills in
  5815. 3:42:02the last query we analyzed the skills
  5816. 3:42:04from a different perspective and found
  5817. 3:42:06what was the average salary for each of
  5818. 3:42:09those skills for a data analyst so
  5819. 3:42:11honestly the easiest solution to
  5820. 3:42:14basically build on the code that we've
  5821. 3:42:15already built is to use a CTE basically
  5822. 3:42:19a CTE for query 4 a CTE for query 3 and
  5823. 3:42:21then combine these two results together
  5824. 3:42:24on something like the skill ID so inside
  5825. 3:42:26VSS code I'm going to create a new file
  5826. 3:42:28called optimal skills give it that
  5827. 3:42:30number CL five the fifth query and up at
  5828. 3:42:33the top of the file I put in what we're
  5829. 3:42:35actually trying to solve for what are
  5830. 3:42:36the most optimal skills to learn and
  5831. 3:42:38we're going to be focus on high demand
  5832. 3:42:40which we've already calculated and then
  5833. 3:42:42High salaries which is already
  5834. 3:42:44calculated as well in query 4 so the
  5835. 3:42:46first thing I'm going to do is going to
  5836. 3:42:47go back and get the query from query 3
  5837. 3:42:51I'm just going to copy that all right
  5838. 3:42:52here and then paste that in remember
  5839. 3:42:54we're going to want to put this inside
  5840. 3:42:56of a CTE we're going to be putting both
  5841. 3:42:58three and four inside of a CTE so I'm
  5842. 3:43:00going to title this with skills demand
  5843. 3:43:04as and then start that CTE right there
  5844. 3:43:07and then from there tab this over remove
  5845. 3:43:10that semicolon and close the parentheses
  5846. 3:43:14Okay so so I have the skills demand
  5847. 3:43:17coming in its own result set using the
  5848. 3:43:19CTE the next thing I want to bring in is
  5849. 3:43:22the number 4 query that we have so I'm
  5850. 3:43:24going to copy this one also and paste it
  5851. 3:43:27over here I'll name this one average
  5852. 3:43:31salary for the temporary result set and
  5853. 3:43:34then start a parenthesis here tab this
  5854. 3:43:37over remove that parenthesis and then
  5855. 3:43:40from there add in another closing
  5856. 3:43:42parentheses right here okay so we have
  5857. 3:43:44our two CTE located right here so I'm
  5858. 3:43:47going go ahead and close out of this and
  5859. 3:43:49close this side window we have what we
  5860. 3:43:50need for this we now need to move into
  5861. 3:43:53actually combining these and if you look
  5862. 3:43:57at it we could technically combine it on
  5863. 3:44:01the skills because each of those skills
  5864. 3:44:04are unique if you will but that's not
  5865. 3:44:07really best practice we need to
  5866. 3:44:09typically whenever you want to combine
  5867. 3:44:11anything you want to combine it on the
  5868. 3:44:13actual um the key at itself the either
  5869. 3:44:16primary or foreign key so we're going to
  5870. 3:44:17be using the skills ID for this so I'm
  5871. 3:44:19going to specify skill ID here and then
  5872. 3:44:23also skill ID here as well now since
  5873. 3:44:26we're going to be combining these I
  5874. 3:44:28don't want to limit this to five and I
  5875. 3:44:30don't want to limit this one to 25 I
  5876. 3:44:32want to combine all of them that way
  5877. 3:44:34they do the agation also I want to speed
  5878. 3:44:36up this query I don't care about an
  5879. 3:44:38order by so I'm going to remove that in
  5880. 3:44:40this case and similarly I'm going to
  5881. 3:44:42remove that as well here and then the
  5882. 3:44:44last thing I'm going to modify is the
  5883. 3:44:46group bu so like I said previously we're
  5884. 3:44:48going to be connecting these two tables
  5885. 3:44:50on the skill ID we can do groupy skills
  5886. 3:44:54it's just not bre practice so we're
  5887. 3:44:56going to change that to the group ey of
  5888. 3:44:58skill ID same thing for the groupy down
  5889. 3:45:01here on skill ID so that way we know for
  5890. 3:45:04sure whenever we do this that we're
  5891. 3:45:06actually aggregating it correctly the
  5892. 3:45:08last minor thing to note is for my
  5893. 3:45:10things we're going to concentrate on
  5894. 3:45:12remote positions with specified salary
  5895. 3:45:15so previously for our query 3 we were
  5896. 3:45:19looking at all the jobs and not
  5897. 3:45:21necessarily those that have or are
  5898. 3:45:24missing a salary value so I'm going to
  5899. 3:45:26select this from query 4 selecting
  5900. 3:45:29salary year average is not null and I'm
  5901. 3:45:31going to also insert it up here as well
  5902. 3:45:34anyway now we have both of these CTE
  5903. 3:45:37built we need to actually move into
  5904. 3:45:39combining them so we're going to move
  5905. 3:45:41into our select statement we're going to
  5906. 3:45:42first identify the skill ID we have this
  5907. 3:45:44in both
  5908. 3:45:45so we're going to just specify the first
  5909. 3:45:47one of skill demand. skill ID next we
  5910. 3:45:51need to identify the skills so we'll do
  5911. 3:45:54similarly with this specifying the skill
  5912. 3:45:57then we need to bring in from query 3
  5913. 3:45:59that demand count along with that
  5914. 3:46:02average salary from query 4 so now when
  5915. 3:46:05you move into combining these we'll use
  5916. 3:46:07a from statement specifying the skills
  5917. 3:46:11demand table or temporary result set and
  5918. 3:46:14then doing an inner join because we only
  5919. 3:46:17care about what exists in both of these
  5920. 3:46:19tables and we're doing this with the
  5921. 3:46:21average salary temporary result set and
  5922. 3:46:24both of these are combined using the
  5923. 3:46:27skills ID so this has the bulk of what
  5924. 3:46:29we need already let's go ahead and run
  5925. 3:46:32this because it's already been too long
  5926. 3:46:34already that I could have made a mistake
  5927. 3:46:36and not caught it so command D command D
  5928. 3:46:39and I did run into an error and it
  5929. 3:46:40resolves around this with statement
  5930. 3:46:42right here so anytime we're doing
  5931. 3:46:44multiple CTE you actually group these
  5932. 3:46:48together so this with keyword transfers
  5933. 3:46:51this into a temporary result set of the
  5934. 3:46:53skills demand and then you put a comma
  5935. 3:46:55and then similarly we do this average
  5936. 3:46:56salary so we're D two CTS right here so
  5937. 3:46:59going ahead and running this command e
  5938. 3:47:01command e and when I added in those
  5939. 3:47:03skill IDs it was ambiguous sometimes
  5940. 3:47:06you'll notice in if you bought the quz
  5941. 3:47:08notes and certificates I'll just include
  5942. 3:47:10all the different table names in front
  5943. 3:47:12of these and that's just so you resolve
  5944. 3:47:15this ambiguity and don't run into these
  5945. 3:47:17different errors like I'm running into
  5946. 3:47:19right now so let's try this one more
  5947. 3:47:23time to see actually if this works
  5948. 3:47:24pressing command e command D and spoke
  5949. 3:47:27too soon again I didn't get all the
  5950. 3:47:29skill IDs again so we got another error
  5951. 3:47:32and saying skills must appear in the
  5952. 3:47:33group by Clause so I'm going go ahead
  5953. 3:47:36actually we already have skills up here
  5954. 3:47:38with our count and that one should be
  5955. 3:47:40fine so I'm going to remove it here
  5956. 3:47:44let's see if if this works all right so
  5957. 3:47:46I've been troubleshooting this skills
  5958. 3:47:49must appear in the group ey and I know
  5959. 3:47:50it can be done and anyway I come to
  5960. 3:47:54realize that compared to our I got to
  5961. 3:47:56close out this so we can actually see it
  5962. 3:47:58so in our first CT We Have Skills ID and
  5963. 3:48:01also skills we want that skills to be in
  5964. 3:48:03there right because we're going to be
  5965. 3:48:05using this and actually displaying this
  5966. 3:48:07in our final table and I don't want to
  5967. 3:48:08do another left joint down the road
  5968. 3:48:10anyway I was specifying the wrong table
  5969. 3:48:12earlier it should be skills job dim and
  5970. 3:48:15in this case I specified now skills di
  5971. 3:48:17to clear up that ambiguity and so now we
  5972. 3:48:21should actually get this to work command
  5973. 3:48:25D command D okay and finally hopefully
  5974. 3:48:28the last error I'm now getting this
  5975. 3:48:29relation average does not exist I'm like
  5976. 3:48:32I know I can do average in here I got a
  5977. 3:48:34dang typo right here on the inner join
  5978. 3:48:37and I specify average space salary so
  5979. 3:48:41wasn't necessarily
  5980. 3:48:42working oh my gosh this is on me right
  5981. 3:48:45now one other typo I don't have skills
  5982. 3:48:51properly in there all right so we're
  5983. 3:48:54finally through that after quite a bit
  5984. 3:48:56of troubleshooting but honestly that's
  5985. 3:48:58what I find myself doing from time to
  5986. 3:49:00time with SLE queries especially when
  5987. 3:49:02combining it sometimes it looks like
  5988. 3:49:04it's easy just to combine two queries
  5989. 3:49:06and put it into a final one and you run
  5990. 3:49:09up to a lot of hiccups along the way so
  5991. 3:49:11I wanted to include that to show that
  5992. 3:49:13sometimes you're going to have to go
  5993. 3:49:13through these troubleshoo shooting steps
  5994. 3:49:15with this anyway we have our results
  5995. 3:49:18back I'm going to move this over to this
  5996. 3:49:19window and we can see from it we have
  5997. 3:49:22our skills our demand count and then the
  5998. 3:49:25average salary associated with it right
  5999. 3:49:28now it's not really in a particular
  6000. 3:49:30order so we need to clean this up it
  6001. 3:49:32looks like it's ordered by skill ID so
  6002. 3:49:34I'm going go down to the bottom of the
  6003. 3:49:36query after the inter join and put in an
  6004. 3:49:38order by and really I care about demand
  6005. 3:49:42first so we're going to put in demand
  6006. 3:49:44and count put in this descending order
  6007. 3:49:48and also you can put more than one
  6008. 3:49:50things to order by so in case ever they
  6009. 3:49:52have the same value we'll go to the
  6010. 3:49:54second value to thus order that one so
  6011. 3:49:56in this case we're going to do the
  6012. 3:49:58average salary and then also do this in
  6013. 3:50:00descending order and finally we're going
  6014. 3:50:02to limit this similar to last time of
  6015. 3:50:04just 25 values so I'm going to go ahead
  6016. 3:50:07and run this query now to get this all
  6017. 3:50:11right so here we have it moving on over
  6018. 3:50:14here here we have our results and right
  6019. 3:50:18now it's ordered by that demand count
  6020. 3:50:20but then we can still see based on what
  6021. 3:50:22we know about some of the higher
  6022. 3:50:23salaries for skills upwards of 150 to
  6023. 3:50:27200,000 we're seeing these high demand
  6024. 3:50:29skills are around 100,000 so I also want
  6025. 3:50:32to see this this table ordered from the
  6026. 3:50:35average salary perspective first so I'm
  6027. 3:50:37going move this around with average
  6028. 3:50:39salary up before the demand count and
  6029. 3:50:42then run this aggregation method again
  6030. 3:50:45command e command e and this time as we
  6031. 3:50:47can see whenever we do it from this
  6032. 3:50:50perspective we are getting these higher
  6033. 3:50:52salaries right here but this demand
  6034. 3:50:55count is so low for these higher salary
  6035. 3:50:59jobs based on what I'm seeing from that
  6036. 3:51:01previous table I'm wondering if we could
  6037. 3:51:04do a wear Clause to limitate by the
  6038. 3:51:07demand count to make sure that we still
  6039. 3:51:09have these high-paying jobs in there and
  6040. 3:51:11ordering it similarly but have a demand
  6041. 3:51:13count grade than 10 so I'm going to add
  6042. 3:51:16in this of where and then specify the
  6043. 3:51:20demand count greater than 10 okay I'm
  6044. 3:51:24going to go ahead and run this new query
  6045. 3:51:26to see what it looks like for this one
  6046. 3:51:29all right and I'm liking this one a lot
  6047. 3:51:30better it's a lot more represen istic of
  6048. 3:51:33what we would expect because there's
  6049. 3:51:34actually values quite AET bit of job
  6050. 3:51:36data values for each of these so just
  6051. 3:51:39analyzing this roughly doing a scan
  6052. 3:51:41through it I can see that once again
  6053. 3:51:44we're seeing that one Cloud tools and
  6054. 3:51:47specifically cloud-based databases are
  6055. 3:51:51some of the highest in here and then
  6056. 3:51:53down here near the middle of this list
  6057. 3:51:55of only 25 we're seeing uh programming
  6058. 3:51:58languages like Python and R now although
  6059. 3:52:01this was a great way to demonstrate the
  6060. 3:52:03use of CTE I would recommend actually
  6061. 3:52:06making this more concise and so that's
  6062. 3:52:08what I did here I went through and
  6063. 3:52:10actually rewrote this entire query
  6064. 3:52:13keeping it uh pretty concise and all it
  6065. 3:52:15basically did was actually combine in
  6066. 3:52:17all those select statements into one
  6067. 3:52:21that were previously spread out among
  6068. 3:52:23those two CTS and I still had the same
  6069. 3:52:25wear group eyes and ordering the only
  6070. 3:52:28thing I'll add is that little last
  6071. 3:52:29caveat at the end where I wanted to have
  6072. 3:52:31the demand count greater than 10 which
  6073. 3:52:34is just an arbitrary number you can't
  6074. 3:52:36put an aggregation method inside of a we
  6075. 3:52:39so I had to do a having keyword here to
  6076. 3:52:42actually do that anyway running this all
  6077. 3:52:44I can do command e command e and
  6078. 3:52:47comparing it to our previous table
  6079. 3:52:49there's our previous tier table on the
  6080. 3:52:50left and then our new table it's the
  6081. 3:52:52exact same results anyway mainly just
  6082. 3:52:54show you this that there's multiple ways
  6083. 3:52:56to actually go through and analyze and
  6084. 3:52:59what can be done and what can't be done
  6085. 3:53:01all right next thing we're doing is
  6086. 3:53:02going to be actually packaging up all of
  6087. 3:53:04our project that we have right here
  6088. 3:53:06generating a readme and then actually
  6089. 3:53:08going out and sharing this project on
  6090. 3:53:11How I would go about doing this all
  6091. 3:53:13right with that I'll see in the next
  6092. 3:53:19one all right so now it's time to
  6093. 3:53:21actually showcase all the different work
  6094. 3:53:23we did and doing this by uploading this
  6095. 3:53:25into GitHub but before we can do that we
  6096. 3:53:28actually need to streamline and put all
  6097. 3:53:31of our analysis into one document so
  6098. 3:53:33inside of vs code right now I have a few
  6099. 3:53:35different folders you may not have this
  6100. 3:53:37Advanced SQL that is all the problems
  6101. 3:53:39that we worked dur in the advanced SQL
  6102. 3:53:40section but you should at least have
  6103. 3:53:42this project SQL folder which has all
  6104. 3:53:44your different SQL files that we worked
  6105. 3:53:46on previously along with that SQL load
  6106. 3:53:50table on how we actually loaded the data
  6107. 3:53:52into the database so let's actually
  6108. 3:53:54upload this all on GitHub and see how it
  6109. 3:53:57looks right now and going into on the
  6110. 3:53:59activity bar on Source control see that
  6111. 3:54:01it has all of our new files I renamed
  6112. 3:54:03one of my files why it's scratched out
  6113. 3:54:05here and I give it this commit message
  6114. 3:54:07of upload SQL files and then press
  6115. 3:54:10commit and then I want to sync changes
  6116. 3:54:12navigating into GitHub can see my
  6117. 3:54:14projects located right here at SQL
  6118. 3:54:16project. job analysis and this right
  6119. 3:54:18here is what everybody's going to be
  6120. 3:54:20seeing when they first get to the
  6121. 3:54:22project and overall there's not a lot
  6122. 3:54:25here as you can see that read me that
  6123. 3:54:26created there's nothing really detailing
  6124. 3:54:28it and you have to navigate into all
  6125. 3:54:30these different folders to even see what
  6126. 3:54:33is going on here like how do you even
  6127. 3:54:34navigate it so here's an example I want
  6128. 3:54:36to work off of I have a course on chat
  6129. 3:54:38GPT for data analytics and then you go
  6130. 3:54:40through and use chat GPT to generate
  6131. 3:54:43code basically gener a project anyway in
  6132. 3:54:46this project here I have for the read me
  6133. 3:54:49it details all the different analysis we
  6134. 3:54:52do for that project there going through
  6135. 3:54:55describing it all and describing all the
  6136. 3:54:56different code that's actually located
  6137. 3:54:58inside the repository so that's what
  6138. 3:55:00we're going to be doing is building out
  6139. 3:55:02a readme in order to handle this so for
  6140. 3:55:05this readme file I want it structured in
  6141. 3:55:07a logical manner to actually go through
  6142. 3:55:10and so somebody can read it and actually
  6143. 3:55:12follow along in all the analysis we did
  6144. 3:55:14so we're going to start with simple
  6145. 3:55:15things like an introduction a background
  6146. 3:55:17and then tools I used from there we're
  6147. 3:55:18going to move into the analysis the
  6148. 3:55:20analysis will be the bulk of the session
  6149. 3:55:22of actually capturing all five of those
  6150. 3:55:24different queries that we analyzed and
  6151. 3:55:26then finally we're going to wrap it up
  6152. 3:55:27with what you learned or what I learned
  6153. 3:55:30during the analysis and then any final
  6154. 3:55:32conclusions that we came to or Drew as
  6155. 3:55:35far as insights so back inside of vs
  6156. 3:55:38code let's actually get to work I have
  6157. 3:55:40the read me here open and I'm going to
  6158. 3:55:42drop in all those different sections
  6159. 3:55:44that we're going to be working on for
  6160. 3:55:46this now conveniently inside of here
  6161. 3:55:48this is this is a text version right
  6162. 3:55:50here so you can insert all this kind of
  6163. 3:55:52text right there but we're going to want
  6164. 3:55:54to open on the right hand side this open
  6165. 3:55:56preview and this allows us to see what
  6166. 3:55:59it's going to look like in the markdown
  6167. 3:56:01version or the final version whenever
  6168. 3:56:03we're actually inside of giip Hub
  6169. 3:56:05specifically if I navigate back to that
  6170. 3:56:07chat gbt one and I navigate here I can
  6171. 3:56:09see like hey it's all formatted stuff
  6172. 3:56:11but if I actually go inside of the read
  6173. 3:56:13me itself and look at the code basically
  6174. 3:56:18it's just a bunch of text and so there's
  6175. 3:56:21certain format that you need to do in
  6176. 3:56:23order to get things like headers here or
  6177. 3:56:26links or whatnot let's go over a few
  6178. 3:56:28brief ones that you should know about as
  6179. 3:56:30we're building this out so the first
  6180. 3:56:32thing is headers I actually all of these
  6181. 3:56:35need to be headers and what do I mean by
  6182. 3:56:37that I'm put a little pound sign right
  6183. 3:56:39here in a space whenever you use that
  6184. 3:56:41that is a header one I can also do two
  6185. 3:56:44pound signs to make a header two or
  6186. 3:56:46header three whatnot for each of these
  6187. 3:56:48I'm going to make them individual header
  6188. 3:56:51ones all right so I have all the
  6189. 3:56:52different headers now I'm going to be
  6190. 3:56:54going through and actually filling this
  6191. 3:56:55out let's start with that introduction
  6192. 3:56:57section first so I make this intro of
  6193. 3:56:59dive into the data job market focusing
  6194. 3:57:01on data analyst roles this project
  6195. 3:57:03explores top paying jobs and demand
  6196. 3:57:05skills and where high demand meets High
  6197. 3:57:07salary in data analytics and then I give
  6198. 3:57:10it this of SQL queries check them out
  6199. 3:57:13more here so need to insert a link so
  6200. 3:57:15for this I want to provide a basically a
  6201. 3:57:18clickable link so I know that it's going
  6202. 3:57:21to be going to this Advanced sorry it's
  6203. 3:57:23going to be going to this project SQL
  6204. 3:57:25folder when they navigate to it I want
  6205. 3:57:27them to see this so I'm going to start
  6206. 3:57:29with some brackets and then from there
  6207. 3:57:30actually Define the folder that we're
  6208. 3:57:32going to and that's project SQL folder
  6209. 3:57:35and that's just what's going to be
  6210. 3:57:36actual viewable then from there I'm
  6211. 3:57:37going to put a parentheses next to it as
  6212. 3:57:39you can notice right here well let me
  6213. 3:57:40close this out right here as you can
  6214. 3:57:42notice it's now again clickable but it's
  6215. 3:57:45not going anywhere so we want to put
  6216. 3:57:47some sort of Link inside of it so I
  6217. 3:57:50press forward slash and then inside of
  6218. 3:57:53here conveniently all the different
  6219. 3:57:54folders pop up that I want to link to
  6220. 3:57:57link to I put project SQL and now it
  6221. 3:58:00should be good so whenever I click this
  6222. 3:58:02it should want to navigate me over as
  6223. 3:58:04you're seeing here but whenever I have
  6224. 3:58:06this in GitHub it will actually navigate
  6225. 3:58:08them over to that folder next up is
  6226. 3:58:11background and I'm not going to bore you
  6227. 3:58:13by reading through all this but
  6228. 3:58:14basically I went through summarized what
  6229. 3:58:16the background for the course was also
  6230. 3:58:17put a link to the course and then from
  6231. 3:58:20there defined the five questions that I
  6232. 3:58:23wanted to be diving into that we did in
  6233. 3:58:25our final project analysis next up is
  6234. 3:58:28tools I used and I wanted to summarize
  6235. 3:58:31four or five main tools of SQL postgress
  6236. 3:58:35vs code and then also git and GitHub and
  6237. 3:58:37I put a little disclaimer across each
  6238. 3:58:39I'm noticing right now so you can use
  6239. 3:58:41something like a Tac or a dash to get it
  6240. 3:58:44in bullet point within here but I'm
  6241. 3:58:46still having a hard time actually
  6242. 3:58:47reading what are these different tools I
  6243. 3:58:49have I can actually bold these different
  6244. 3:58:52values by putting double asteris before
  6245. 3:58:56and after any value it then goes ahead
  6246. 3:58:58and bold cases it all right next up is
  6247. 3:59:00the analysis we're going to start first
  6248. 3:59:03with just putting a blanket statement of
  6249. 3:59:04what we're actually doing here that
  6250. 3:59:06we're aiming at investigating specific
  6251. 3:59:08aspects this is can to be broken up into
  6252. 3:59:09multiple sections so the first one I
  6253. 3:59:11used a header three and then specified
  6254. 3:59:13hey it's number one one one that we did
  6255. 3:59:15of top paying data l jobs by the way
  6256. 3:59:17we're not going to go through all five
  6257. 3:59:18we're going to do one of these from
  6258. 3:59:20there I'm going to put a quick summary
  6259. 3:59:21in and so for this one it was just hey
  6260. 3:59:24to identify the highest paying roles and
  6261. 3:59:26then what I filtered it by and
  6262. 3:59:27everything like that now I want to
  6263. 3:59:29showcase my code from this query so that
  6264. 3:59:31way they don't necessarily have to go
  6265. 3:59:33back to this file right here and
  6266. 3:59:35actually see it instead I'm going to
  6267. 3:59:37copy this code right here I'm going to
  6268. 3:59:39close this panel we're get a little
  6269. 3:59:40smoed and I'm going to put it into here
  6270. 3:59:43the problem is if you look at it it
  6271. 3:59:45looks like a hot mess over here so what
  6272. 3:59:47we can actually do is format this as a
  6273. 3:59:49code block so for this I'm going to put
  6274. 3:59:51three back ticks one at the beginning
  6275. 3:59:54and then one at the end and so if you
  6276. 3:59:57look inside of here now we can see that
  6277. 3:59:59this is all formatted correctly and it
  6278. 4:00:01actually looks like SQL code
  6279. 4:00:03additionally it's good practice inside
  6280. 4:00:05of here to specify what language this is
  6281. 4:00:09and so inside of this markdown file
  6282. 4:00:11right here it actually if you notice
  6283. 4:00:13that it form formatted it for what it is
  6284. 4:00:15here and similarly it's doing that here
  6285. 4:00:18as well with this color highlighting so
  6286. 4:00:19making it a lot easier to read so
  6287. 4:00:21definitely recommend doing that
  6288. 4:00:22following this clo boock I wanted to top
  6289. 4:00:25this all off with the findings so I put
  6290. 4:00:27in here hey here's the breakdown of the
  6291. 4:00:29top. UN list jobs in 2023 and then had
  6292. 4:00:32three different insights of the results
  6293. 4:00:34that we had found earlier now if you
  6294. 4:00:36recall from earlier during that second
  6295. 4:00:38query when we dived into it I had chat
  6296. 4:00:40gbt visualized the data that was
  6297. 4:00:43provided well I also had Chad gbt
  6298. 4:00:46visualize the results from this as well
  6299. 4:00:49to showcase the different salaries
  6300. 4:00:52associated with the top 10 jobs anyway I
  6301. 4:00:55want to show some of these
  6302. 4:00:56visualizations inside of here to better
  6303. 4:00:59convey some of the analysis that we did
  6304. 4:01:01here so anytime we need to include these
  6305. 4:01:04type of images inside of marktown we
  6306. 4:01:06actually have to include the images
  6307. 4:01:08inside of the project file itself so I'm
  6308. 4:01:11going to create a new folder called
  6309. 4:01:13assets
  6310. 4:01:14now this option of including an image
  6311. 4:01:17inside of here is completely optional
  6312. 4:01:19whether you want to do it or not but it
  6313. 4:01:20shows even more functionality of how to
  6314. 4:01:22use markdown anyway I can take that
  6315. 4:01:25folder or take that file itself and then
  6316. 4:01:28go ahead and drop it into here and so we
  6317. 4:01:30can see it's right here in top hang
  6318. 4:01:33roles I'm going to go ahead and then go
  6319. 4:01:36and select copy relative path now in
  6320. 4:01:39order to display an image in markdown
  6321. 4:01:41you need to use this nomenclature here
  6322. 4:01:43where you're going to have an
  6323. 4:01:44exclamation point and then brackets
  6324. 4:01:46around some sort of alternate text for
  6325. 4:01:48this I'm going to name this top paying
  6326. 4:01:51rules next we need to do that URL so I
  6327. 4:01:54copied that relative path I'm going to
  6328. 4:01:56go ahead and paste it in you notice
  6329. 4:01:59whenever I do that now it's accessing it
  6330. 4:02:01right here from our folder so then I
  6331. 4:02:03just end this off with a little comment
  6332. 4:02:05at the end in italics that hey this is
  6333. 4:02:08the bar graph visualizing these results
  6334. 4:02:10and also that chat GPT generated this
  6335. 4:02:12graph for my SQL query results all right
  6336. 4:02:14so now I'm going to repeat this for all
  6337. 4:02:17five of those other areas as well all
  6338. 4:02:20right so I've gone through and put all
  6339. 4:02:22this in this took me about uh like 30
  6340. 4:02:24minutes to go through and do right so
  6341. 4:02:27here's what I did very similar to that
  6342. 4:02:28first section as I continue the same
  6343. 4:02:31layout of just outlining it and then
  6344. 4:02:33providing an a quick snapshot of what
  6345. 4:02:35the breakdown is and then if I had a
  6346. 4:02:37graph I included it now when I got down
  6347. 4:02:40here into queries 3 4 and 5 I found
  6348. 4:02:43visualization were less uh helpful for
  6349. 4:02:46this so I started inserting tables did
  6350. 4:02:48that for both four and then also for
  6351. 4:02:51five proving that final analysis now
  6352. 4:02:53tables themselves are pretty easy to put
  6353. 4:02:56into markdown you can put it in with
  6354. 4:02:58this format right here I found that
  6355. 4:03:00actually just copying and pasting the
  6356. 4:03:03results from here in vs code into
  6357. 4:03:05something like Chachi BT and having to
  6358. 4:03:07get format for me saves a lot of time so
  6359. 4:03:10that's what I did for a lot of this so
  6360. 4:03:13last two sections that I'm going to
  6361. 4:03:15include the one is what I learned this
  6362. 4:03:18really going to be dependent on your
  6363. 4:03:19situation where you are in your Learning
  6364. 4:03:21Journey I just put in these three
  6365. 4:03:23examples of hey we worked on querying
  6366. 4:03:26data aggregation and then also just
  6367. 4:03:28getting into actually analyzing so I
  6368. 4:03:30named it analytically wizardy all right
  6369. 4:03:32the last section to move into is the
  6370. 4:03:33conclusions and I'm going to break this
  6371. 4:03:35into two separate sections first is
  6372. 4:03:40insights and I'm going to just capture
  6373. 4:03:42all the different ins sites that we had
  6374. 4:03:44up here from before and captured into
  6375. 4:03:47just five main different value points
  6376. 4:03:49that I found from this analysis and then
  6377. 4:03:52finally I'm going to have some closing
  6378. 4:03:54thoughts for this section I'd really be
  6379. 4:03:56looking at what you actually took away
  6380. 4:04:00holistically from this project for me
  6381. 4:04:02just working on this alone really built
  6382. 4:04:05up my sequel skills although I'm already
  6383. 4:04:07you know pretty confident in those
  6384. 4:04:09skills I feel actually going through and
  6385. 4:04:10teaching you through this I learned a
  6386. 4:04:12lot myself so so I put a lot of that in
  6387. 4:04:14the closing thoughts here anyway so this
  6388. 4:04:16read me has everything we need inside of
  6389. 4:04:18it I'm going to go ahead and save it and
  6390. 4:04:21then I'm going to upload it into GitHub
  6391. 4:04:23for this it's going to be committing
  6392. 4:04:24those two images that I had in the
  6393. 4:04:26readme along with the changes to the
  6394. 4:04:28readme so now when I actually go to this
  6395. 4:04:32project here I actually have a fullblown
  6396. 4:04:35layout of all the different work we did
  6397. 4:04:39and all different analysis here I'm
  6398. 4:04:41pretty blown away this is a lot of work
  6399. 4:04:42we put into this you should be super
  6400. 4:04:44proud of this the other thing I'd
  6401. 4:04:46suggest is actually pinning this
  6402. 4:04:48repository to your profile so you can
  6403. 4:04:50come up here to customize your pins and
  6404. 4:04:53I'm going to come and select this SQL
  6405. 4:04:55project data analysis and save those
  6406. 4:04:57pins and then from here if I wanted to I
  6407. 4:04:59can drag it around and even put it up at
  6408. 4:05:01the top all right now that we built this
  6409. 4:05:04entire file and this readme we need to
  6410. 4:05:06go forward with actually showcasing it
  6411. 4:05:08so that's what we'll be doing in the
  6412. 4:05:09next section of actually getting this
  6413. 4:05:11onto something like your LinkedIn to
  6414. 4:05:13show case as experience all right with
  6415. 4:05:16that I'll see you in the next
  6416. 4:05:21one de nerds congratulations on making
  6417. 4:05:23it to the end of the course been nothing
  6418. 4:05:25short of your hard work and there's a
  6419. 4:05:28couple steps I'd recommend taking
  6420. 4:05:30further now and actually showcase your
  6421. 4:05:32work so it's been great that you put
  6422. 4:05:33this work on GitHub but now you need to
  6423. 4:05:35get the word out and I recommend doing
  6424. 4:05:37this via LinkedIn there's three main
  6425. 4:05:39things you can do for this one add the
  6426. 4:05:41certificate of completion for those that
  6427. 4:05:42purchased course no certificates which
  6428. 4:05:44it's not too late to do that you can add
  6429. 4:05:46this to your profile another thing you
  6430. 4:05:48can do is with your GitHub project now
  6431. 4:05:50on the internet you can also showcase
  6432. 4:05:52this project on your LinkedIn profile
  6433. 4:05:55and the last and third thing that we'll
  6434. 4:05:56cover is a social media post so after
  6435. 4:05:59you complete the end of course survey I
  6436. 4:06:02will send you an email via an Automation
  6437. 4:06:05and you'll receive the certificate of
  6438. 4:06:07completion with this email you can go
  6439. 4:06:09ahead and then download that certificate
  6440. 4:06:11to your computer after that you should
  6441. 4:06:13never over to LinkedIn specifically to
  6442. 4:06:15your profile and in it make sure that
  6443. 4:06:18you have your certificate section and
  6444. 4:06:19also your project section enabled within
  6445. 4:06:22your profile by going underneath the
  6446. 4:06:23recommended and adding these two for the
  6447. 4:06:26certificate you just navigate to that
  6448. 4:06:28section click the plus icon and then
  6449. 4:06:30from there fill it out most of the
  6450. 4:06:32information here is self-explanatory for
  6451. 4:06:34the issuing organization you'll be able
  6452. 4:06:35to put in my name of Luke barus for the
  6453. 4:06:38skills I would list these five core
  6454. 4:06:40skills of SQL postgress and SQL light
  6455. 4:06:43now if you did the GitHub portion of
  6456. 4:06:44this you can also put in git and GitHub
  6457. 4:06:46finally it has an option to add media
  6458. 4:06:48and you can go through and actually
  6459. 4:06:50upload that certificate that you had
  6460. 4:06:52from previously from there click apply
  6461. 4:06:54this obviously in my certificate so I'm
  6462. 4:06:56not going to save it now for sharing
  6463. 4:06:57your project you're going to navigate
  6464. 4:06:59down to the project section and then
  6465. 4:07:01click similarly that add icon now this
  6466. 4:07:03one's also pretty self-explanatory
  6467. 4:07:05you're going to put in that project name
  6468. 4:07:06a short little description I have about
  6469. 4:07:08what I did and what I investigated and
  6470. 4:07:10what I found similarly I put in the same
  6471. 4:07:11skills that I had in the certificate
  6472. 4:07:13section
  6473. 4:07:14and if you obviously you did the project
  6474. 4:07:16and you listed a GitHub you can list get
  6475. 4:07:17in GitHub when it gets to add media
  6476. 4:07:20that's where you want to actually go in
  6477. 4:07:21and add the link to your GitHub
  6478. 4:07:24repository and this way it can be
  6479. 4:07:26actually directed them right to it from
  6480. 4:07:29there put that start and end date
  6481. 4:07:30everything else can pretty much be left
  6482. 4:07:31blank and for this one I'm going to go
  6483. 4:07:33ahead since I actually did do this
  6484. 4:07:35project I'm going to go ahead and save
  6485. 4:07:36it so now that we've both showcased our
  6486. 4:07:38certificate and also this project the
  6487. 4:07:40last thing we have to do is just make a
  6488. 4:07:42social media post you prompt you either
  6489. 4:07:44after the certificate or even this
  6490. 4:07:45project to maybe start a post now for
  6491. 4:07:47this post feel free to tag both me and
  6492. 4:07:49also Kelly the co-creator of this course
  6493. 4:07:52in your post I love seeing everybody's
  6494. 4:07:54progress and specifically diving in and
  6495. 4:07:56actually checking out your different
  6496. 4:07:57projects so I'm looking forward to
  6497. 4:07:59seeing that all right once again
  6498. 4:08:01congratulations on wrapping up this
  6499. 4:08:03pretty hefty course on SQL I feel like
  6500. 4:08:05it captures everything that you need to
  6501. 4:08:07know to dive in and be confident in your
  6502. 4:08:09skills no matter what the field you're
  6503. 4:08:11working on in data science is for what
  6504. 4:08:13to learn next you probably learn from
  6505. 4:08:15the data that python is another popular
  6506. 4:08:18skill and I'll have a tutorial for that
  6507. 4:08:20coming real soon so stay tuned but until
  6508. 4:08:23then I find that chat gbt speeds up my
  6509. 4:08:26process a lot in data analytics so if
  6510. 4:08:29you're curious about that check out this
  6511. 4:08:31video right here also for those that
  6512. 4:08:33didn't buy the course notes certificate
  6513. 4:08:35still not too late check out this link
  6514. 4:08:37right here with that I'll see you in the
  6515. 4:08:39next one

About this transcript

This page contains the full transcript of SQL for Data Analytics - Learn SQL in 4 Hours by Luke Barousse, generated from the public captions YouTube serves with the video. The transcript has 48,224 words across 6,515 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.