filmov
tv
Mastering SQL Joins Using ChatGPT to Combine Tables
![preview_player](https://i.ytimg.com/vi/KvgNE5jGcvU/maxresdefault.jpg)
Показать описание
Published on 10 Jul 2023:
In this video, we will learn to generate a simple sql using ChatGPT.
We will combine two tables and get a sql.
Steps/Prompts followed are below:
Steps:
1. I have two tables in sql server FactInternetSales and DimDate.
2. I want to join the orderdatekey in FactInternetSales with datekey in DimDate.
3. I want to get the sum of SalesAmount in FactInternetSales based on EnglishMonthName and CalendarYear in DimDate table.
I need TSQL for the same
4. database name is AdventureWorksDW2017
5. please order by calendar year and month
6. month name are alphabetical. Can we please sort on month number based on month name
SQL generated is copied below:
SELECT d.EnglishMonthName, d.CalendarYear, SUM(s.SalesAmount) AS TotalSalesAmount
GROUP BY d.EnglishMonthName, d.CalendarYear
ORDER BY d.CalendarYear,
CASE
WHEN d.EnglishMonthName = 'January' THEN 1
WHEN d.EnglishMonthName = 'February' THEN 2
WHEN d.EnglishMonthName = 'March' THEN 3
WHEN d.EnglishMonthName = 'April' THEN 4
WHEN d.EnglishMonthName = 'May' THEN 5
WHEN d.EnglishMonthName = 'June' THEN 6
WHEN d.EnglishMonthName = 'July' THEN 7
WHEN d.EnglishMonthName = 'August' THEN 8
WHEN d.EnglishMonthName = 'September' THEN 9
WHEN d.EnglishMonthName = 'October' THEN 10
WHEN d.EnglishMonthName = 'November' THEN 11
WHEN d.EnglishMonthName = 'December' THEN 12
END;
Link to the chat:
SUBSCRIBE to learn more about Power BI,Power Query, Power Pivot, Excel,SQL Server and Python!!
Our Playists:
ABOUT DAGDOO:
Website:
Questions? Comments and SUGESTIONS? You will find me here:
Twitter: @dagdooe
Category: Science & Technology
License: Standard YouTube License
In this video, we will learn to generate a simple sql using ChatGPT.
We will combine two tables and get a sql.
Steps/Prompts followed are below:
Steps:
1. I have two tables in sql server FactInternetSales and DimDate.
2. I want to join the orderdatekey in FactInternetSales with datekey in DimDate.
3. I want to get the sum of SalesAmount in FactInternetSales based on EnglishMonthName and CalendarYear in DimDate table.
I need TSQL for the same
4. database name is AdventureWorksDW2017
5. please order by calendar year and month
6. month name are alphabetical. Can we please sort on month number based on month name
SQL generated is copied below:
SELECT d.EnglishMonthName, d.CalendarYear, SUM(s.SalesAmount) AS TotalSalesAmount
GROUP BY d.EnglishMonthName, d.CalendarYear
ORDER BY d.CalendarYear,
CASE
WHEN d.EnglishMonthName = 'January' THEN 1
WHEN d.EnglishMonthName = 'February' THEN 2
WHEN d.EnglishMonthName = 'March' THEN 3
WHEN d.EnglishMonthName = 'April' THEN 4
WHEN d.EnglishMonthName = 'May' THEN 5
WHEN d.EnglishMonthName = 'June' THEN 6
WHEN d.EnglishMonthName = 'July' THEN 7
WHEN d.EnglishMonthName = 'August' THEN 8
WHEN d.EnglishMonthName = 'September' THEN 9
WHEN d.EnglishMonthName = 'October' THEN 10
WHEN d.EnglishMonthName = 'November' THEN 11
WHEN d.EnglishMonthName = 'December' THEN 12
END;
Link to the chat:
SUBSCRIBE to learn more about Power BI,Power Query, Power Pivot, Excel,SQL Server and Python!!
Our Playists:
ABOUT DAGDOO:
Website:
Questions? Comments and SUGESTIONS? You will find me here:
Twitter: @dagdooe
Category: Science & Technology
License: Standard YouTube License