Basic SQL Statements
Basic SQL Statements
Basic SQL Statements
STATEMENTS
Lab 2
BikeStore Schema
Load BikeStore Database to SQL Server
Data Manipulation Language (DML)
• Select Statement
---select specific columns
SELECT first_name, last_name, ...
FROM sales.customers;
--Using TOP WITH TIES to include rows that match the values in the
last row
SELECT top 3 with ties product_name,list_price
FROM production.products
ORDER BY list_price DESC;
DML (SELECT /inner Join)
SELECT product_name,category_name, list_price
FROM production.products p INNER JOIN production.categories c
ON c.category_id = p.category_id
ORDER BY product_name DESC;
DML (SELECT /left Join)
We need to retrieve all product with it’s order
number
SELECT product_name, order_id
FROM production.products p LEFT JOIN
sales.order_items o
ON o.product_id = p.product_id
ORDER BY product_name;
update production.products
set list_price=1500;