WEBVTT

00:00.000 --> 00:04.960
All right, so now it's time for you to get hands-on using ChatvT to help you write your SQL queries.

00:05.680 --> 00:10.400
In vision, that you're a data analyst. And you're trying to think of what are things that I would

00:10.400 --> 00:16.000
want to know about my data. You'd want to look at your sales. Start to understand your sales.

00:16.640 --> 00:22.480
For example, in 2021, where did our revenue come from? How has it distributed across our states?

00:22.480 --> 00:29.200
How much money are we making per state? Second, another example. How much are sales growing

00:29.200 --> 00:35.920
or shrinking? What's that year-over-year revenue change? Let's compare our revenue from 2020

00:35.920 --> 00:43.040
to 2021. What's that change? Your challenge is for you to write these queries using the help

00:43.040 --> 00:50.080
of ChatvT. So instead of you writing it yourself, prompt ChatvT to get it to write the SQL queries

00:50.080 --> 00:55.680
for you. Additionally, aside from these examples, are there any other ideas that you can come up with?

00:55.680 --> 01:01.440
Think about what we have in our database and what are some questions you could ask and try to

01:01.440 --> 01:06.240
get ChatvT to write those queries for you. As you're doing this, here's a few things that keep

01:06.240 --> 01:11.520
in mind. So that you don't have to explain your database to ChatvT, take a screenshot and upload

01:11.520 --> 01:16.880
that. That way, it'll know your table and column names and can write your queries so they work

01:16.880 --> 01:21.680
without you having to insert those names manually yourself. I'll show you a couple tips on how to

01:21.840 --> 01:29.520
do that easily in just a moment. Tell ChatvT which flavor of SQL you're writing. So if you're using

01:29.520 --> 01:35.040
Postgres or SQL Server, make sure you make that clear because otherwise it might assume the wrong

01:35.040 --> 01:43.760
one. Once you're done, test your code. Make sure it runs. Look at the results. Does it pass this

01:43.760 --> 01:50.480
sniff test? Does everything seem right? Look at the code. See if it makes sense. Run it and take a

01:50.480 --> 01:57.920
look at the results. The results make sense. As you're doing this, if you just have one long chat

01:57.920 --> 02:03.600
and you're asking multiple things to do different things, sometimes it can get hung up or remember

02:03.600 --> 02:08.960
things that it was working on and think that you just want to keep changing the current SQL query.

02:08.960 --> 02:14.800
So if you want to do a completely different query, consider making a new Chat for different tasks

02:14.960 --> 02:19.920
or different queries instead of just keeping one long running Chat in ChatvT.

02:22.000 --> 02:27.600
So here are some tips of creating your screenshots of your database structure. Here in Debeaver,

02:27.600 --> 02:33.760
I can double click on my tables and click on the diagram here to see my entity relationship diagram.

02:34.480 --> 02:39.760
If there's tables that I'm not interested in or views or things that I want to delete, I can select

02:40.720 --> 02:46.400
those and then I can do a right click or a control click and delete those. So anything that I'm not

02:46.400 --> 02:53.920
interested in, I can just get rid of those from my diagram. And then whatever I'm left over with,

02:53.920 --> 03:00.560
then I could, again, right click or control click and save this diagram as a screenshot,

03:01.440 --> 03:07.520
essentially as a PNG image. And I can save that wherever I want. Go to ChatvT,

03:08.480 --> 03:12.560
click the plus and upload it from my computer. So that's one way to do it.

03:13.600 --> 03:19.200
But a faster way to do it might be if let's say you're on on a Mac and you just want to do a

03:19.200 --> 03:22.880
screenshot. So let's say you don't want to edit and do all of that stuff. Let me close these

03:22.880 --> 03:27.120
without saving changes to it. When you just double click to open this up and you look at your

03:27.120 --> 03:32.640
diagram here, if I just want to screenshot a certain area of this on the Mac, I can hit command

03:32.640 --> 03:38.240
shift four. And after I hit command shift four, I can then drag over the area that I want a

03:38.240 --> 03:43.920
screenshot. And before I let go, I want to copy this to my clipboard so I can simply paste it into

03:43.920 --> 03:52.800
ChatvT. So before I let go, I'm going to hold control. So I hit command shift four, drag over the area,

03:54.160 --> 03:59.920
before I let go, hold control while I let go, that gets copied to my clipboard. Now I can go to

03:59.920 --> 04:09.520
ChatvT and I can simply paste with command V and it paste into ChatvT. If I'm creating a database

04:09.520 --> 04:15.680
diagram for SQL Server in SQL Server Management Studio, I can right click here on my database

04:15.680 --> 04:20.480
diagrams and create a new diagram just with the tables that I'm interested in. You might not be

04:20.480 --> 04:24.240
able to save this, but in this case, even though I can't save it, that's okay. I can still create

04:24.320 --> 04:31.040
the diagram and I can select the tables that I want to add to it. And once I'm done here, I can

04:31.040 --> 04:40.320
then copy that diagram to my clipboard. So here I can right click and copy it to my clipboard.

04:41.280 --> 04:46.480
Now if you can't paste, like here I'm hitting control V to paste and it's not working, then we just

04:46.480 --> 04:53.040
have to go through something like paint and open that up and do a paste with the control V,

04:53.760 --> 04:58.800
and then copy it from here. So control C once again and then I can go and paste

04:59.600 --> 05:06.000
in there and then you've got your database diagram. So go ahead and take up your challenge

05:06.000 --> 05:11.840
and see how you do and in the next video we'll come back and talk through and see how we might

05:11.840 --> 05:13.440
approach this.

