SQL Output
SQL Output
create table salesman_table(salesmanId int, SalesmanName varchar(255), Commission int, City var
create table orders_table(OrderId int, CustomerId int, SalesmanId int, Orderdate varchar(255),
--Tasks to be performed
--1. Insert a new record in your Orders table.
--2. Add Primary key constraint for SalesmanId column in Salesman table. Add default
--constraint for City column in Salesman table. Add Foreign key constraint for SalesmanId
--column in Customer table. Add not null constraint in Customer_name column for the
--Customer table.
alter table salesman_table add constraint df_c default 'Texas' for city
alter table customer_table add constraint fr_key foreign key(salesmanid) references salesman
--Add not null constraint in Customer_name column for the customer table.
--3. Fetch the data where the Customer’s name is ending with ‘N’ also get the purchase
-- amount value greater than 500.
select * from customer_table where CustomerName like '%n' and PurchaseAmount > 500
--4. Using SET operators, retrieve the first result with unique SalesmanId values from two
--tables, and the other result containing SalesmanId with duplicates from two tables.
--5. Display the below columns which has the matching data.
-- Orderdate, Salesman Name, Customer Name, Commission, and City which has the
-- range of Purchase Amount between 500 to 1500.
--6. Using right join fetch all the results from Salesman and Orders table.