Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notes in learning #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"files.autoSave": "afterDelay",
"screencastMode.onlyKeyboardShortcuts": true,
"terminal.integrated.fontSize": 18,
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Visual Studio Dark",
"workbench.fontAliasing": "antialiased",
"workbench.statusBar.visible": true,
Expand Down
2 changes: 1 addition & 1 deletion Chapter 2/Finding Duplicate Rows/Duplicate2.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT FirstName, LastName, COUNT(1)
FROM Customer
GROUP BY FirstName, LastName
HAVING COUNT(1) > 1
HAVING COUNT(1) > 1 -- check duplicate
6 changes: 3 additions & 3 deletions Chapter 2/Finding Inaccurate Data Values/CheckOrderTotal.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SELECT OrderItem.OrderId,
Orders.TotalDue,
SUM(Price * Quantity) as NewTotalDue
Orders.TotalDue, -- compare totalDue
SUM(Price * Quantity) as NewTotalDue -- with newTortalDue
FROM OrderItem
JOIN Product ON OrderItem.ProductID = Product.ProductID
JOIN Orders ON OrderItem.OrderID = Orders.OrderID
GROUP BY OrderItem.OrderId,
Orders.TotalDue
Orders.TotalDue;
3 changes: 1 addition & 2 deletions Chapter 2/Using Data Types/SelectCustomerOrdersSum.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ From Customer
GROUP BY Customer.CustomerID,
FirstName,
LastName
ORDER BY Sum(TotalDue) DESC
LIMIT 10 -- Click on Run on active connection to run
ORDER BY Sum(TotalDue) DESC -- Click on Run on active connection to run
3 changes: 2 additions & 1 deletion Chapter 3/Filtering By Dates/WithCurrentDateMinus10years.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SELECT OrderID, CreationDate
FROM Orders
Where Year(CreationDate) > (Year(Now()) - 10);
Where Year(CreationDate) > (Year(Now()) - 10);
-- more than past 10 years now
10 changes: 5 additions & 5 deletions Chapter 4/Common SQL String Functions/Trim.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT TRIM(
'M'
FROM ProductCode
) AS TrimmedProductCode
FROM Product
SELECT TRIM('M'FROM ProductCode) AS TrimmedProductCode
FROM Product;

-- working only leading and trailing
SELECT TRIM('0' FROM ProductCode) FROM Product;