SQL Assignments
SQL Assignments
SQL Assignments
--------------------------------------------------------------------------------------------------------------------------------------
Create new table and insert below data, Delete the record where customer_name are
Andrew Smith and Michael Smith.
Return the Customer_name, city and order_amount from the Orders_Testing table where
order_date < '2017-04-06'
Delete the record where Order_amount greater than < 15000
order_id INT,
order_date DATE,
customer_name VARCHAR(250),
city VARCHAR(100),
order_amount MONEY
)
UNION ALL
UNION ALL
UNION ALL
UNION ALL
UNION ALL
UNION ALL
UNION ALL
UNION ALL
UNION ALL
Return the FirstName and LastName column from Emp table. Return a third column that
outputs “Promotion 1” if the "position" column value is Manager, “Manager_Asia” if the
EmailPromotion value is Senior Associate, and “Senior Associate Euro” Else it should be
represent the column values "position".
Using the employees table, complete a CASE statement that returns the string “Long Name”
if the FirstName column is at least five(5) characters long. If the FirstName column is less
than ten characters, return the string “Short Name”.
Joins -
Using the Person.Person and Person.Password tables, INNER JOIN the two tables using the
BusinessEntityID column and return the FirstName and LastName columns from
Person.Person and then PasswordHash column from Person.Password.
Return the BusinessEntityID and SalesYTD column from Sales.SalesPerson.Join this table to
the Sales.SalesTerritory table in such a way that every in Sales.SalesPerson will be returned
regardless of whether or not they are assigned to a territory. Also, return the Name column
from Sales.SalesTerritory. Give this column the column alias “Territory Name”.
Using the previous example as your foundation, join to the Person.Person table to return the
sales person’s first name and last name. Now, only include those rows where the territory’s
name is either “Northeast” or “Central”