SQL Assignment 1
SQL Assignment 1
SalesmanId INT,
Name VARCHAR(255),
City VARCHAR(255),
Age INT
);
VALUES
SalesmanId INT,
CustomerId INT,
CustomerName VARCHAR(255),
PurchaseAmount INT,
);
VALUES
CREATE TABLE Orders (OrderId int, CustomerId int, SalesmanId int, Orderdate Date,
Amount
money)
(5001,2345,101,'2021-07-01',550),
(5003,1234,105,'2022-02-15',1500)
--Fetching the data where the Customer’s name is ending with ‘N’:-
--Using SET operators, retrieve the first result with unique SalesmanId values from
two tables:-
Except
--And the other result containing SalesmanId with duplicates from two tables:-
union all
--Displaying the below columns which has the matching data - orderdate
name,customername,commission and city which has the range of purchase
between 500 to 1500:-
select orderdate,name,customername,commission,city from
Salesman,Customer,Orders where purchaseamount between 500 and 1500;
--Using right join fetch all the results from Salesman and Orders table:-
select
salesmanid,name,commission,city,age,salesmanidalesmanid,orderid,customerid,ord
erdate,amount
from Salesman
on salesman.SalesmanId = orders.OrderId;