Class Date : 16 January – 2025
Get Northwind Database for SQL Server from : https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/instnwnd.sql
select * from Customers;
SELECT CustomerID, ContactName , City FROM Customers;
— Filter records
SELECT CustomerID, ContactName , City, ContactTitle FROM Customers WHERE City = ‘Madrid’;
SELECT CustomerID, ContactName , City, ContactTitle
FROM Customers
WHERE ContactTitle = ‘Owner’ AND City=’Madrid’
— Owners of Madrid City
— Logical Operators
SELECT * FROM Products WHERE UnitPrice > 40 AND ReorderLevel >= 25;
— Price is greater than 30 but less than 60
SELECT * FROM Products WHERE UnitPrice > 30 AND UnitPrice < 60;
SELECT * FROM Products WHERE UnitPrice BETWEEN 30 AND 60;
— OR Logical Operator
— Madrid ya London ke customers
SELECT * FROM Customers WHERE City = ‘London’ OR City = ‘Madrid’ OR City = ‘Barcelona’
SELECT * FROM Customers WHERE City IN (‘London’,’Madrid’, ‘Barcelona’)
——- Sorting of Data
SELECT * FROM Orders ORDER BY RequiredDate ASC;
SELECT * FROM Products ORDER BY UnitPrice ASC;