Exercise 5
Exercise 5
Exercise 5
2.Write a SQL query to combine each row of the salesman table with each row of the
customer table
4.Write a SQL statement to create a Cartesian product between salesperson and customer, i.e.
each salesperson will appear for every customer and vice versa for those salesmen who
belong to a city and customers who require a grade
select * from salesman cross join customer where salesman.city is not null and
customer.grade>0;
5.Write a SQL statement to make a Cartesian product between salesman and customer i.e.
each salesman will appear for all customers and vice versa for those salesmen who must
belong to a city which is not the same as his customer and the customers should have their
own grade.
select * from salesman cross join customer where salesman.city!=customer.city and
customer.grade>0;
Creating the table edetails:
8.From the following tables write a SQL query to find the names of departments where more
than two employees are employed. Return dpt_name.
9.From the following tables write a SQL query to display the first and last names of each
employee, as well as the department name and sanction amount.
select emp_fname,emp_lname,dept_name,dept_allot from edetails INNER JOIN emdept ON
edetails.emp_dept=emdept.dept_code;
10.From the following tables write a SQL query to find the details of an order. Return
ord_no, ord_date, purch_amt, Customer Name, grade, Salesman, commission.