SQL_Question_33_Complete_Solution (1)
SQL_Question_33_Complete_Solution (1)
SQL Query:
INSERT INTO STUDENT (StdID, StdName, Sex, Percentage, SClass, Sec, Stream, DOB)
VALUES
(1, 'John Smith', 'Male', 85, 12, 'A', 'Science', '2005-06-20'),
(2, 'Mary Adams', 'Female', 75, 11, 'B', 'Commerce', '2006-07-15'),
(3, 'Sam Watson', 'Male', 90, 12, 'A', 'Science', '2005-05-10'),
(4, 'Emily Jones', 'Female', 82, 10, 'C', 'Commerce', '2007-08-22'),
(5, 'Harry White', 'Male', 65, 11, 'A', 'Science', '2006-04-18'),
(6, 'Clara Brown', 'Female', 92, 12, 'B', 'Science', '2005-11-11'),
(7, 'Kevin Grey', 'Male', 45, 10, 'C', 'Commerce', '2007-12-04'),
(8, 'Lily Black', 'Female', 78, 11, 'A', 'Commerce', '2006-10-27'),
(9, 'George Blue', 'Male', 55, 12, 'A', 'Science', '2005-03-03'),
(10, 'Nina Green', 'Female', 88, 10, 'B', 'Science', '2007-01-05');
OUTPUT
SQL Query:
OUTPUT
c) Display the details of all students scoring above 80%
SQL Query:
OUTPUT
d) Display the names of all students from the Science stream arranged by
percentage
SQL Query:
OUTPUT
e) To add a column TeacherID in the table
SQL Query:
SQL Query:
OUTPUT
g) To display the details of all students who are not in Science stream
SQL Query:
OUTPUT
h) To increase the percentage of all students by 2, who are having percentage
less than 40
SQL Query:
UPDATE STUDENT
SET Percentage = Percentage + 2
WHERE Percentage < 40;
OUTPUT
SQL Query:
OUTPUT
SQL Query:
OUTPUT
k) To display the total number of male and female students
SQL Query:
OUTPUT
QUESTION 34 Create a table 2 store employee details are shown below and
right SQL command for the following .
Write a query to display EName and Sal of employees whose salary are greater
than or equal to 2200?
SQL QUERY
OUTPUT
b. Write a query to display details of employees who are not getting
commission?
SQL QUERY
OUTPUT
c. Write a query to display employee name and salary of those employees who
don't have their salary in range of 2500 to 4000?
SQL QUERY
OUTPUT
d. Write a query to display the name, job title and salary of employees who
don't have a manager?
SQL QUERY
OUTPUT
e. Write a query to display the name of employee whose name contains 'L' as
third alphabet?
SQL QUERY
OUTPUT
f. Write a query to display the name of employee whose name contains 'T' as
last alphabet?
SQL QUERY
OUTPUT
g. Write a query to display the name of employee whose name contains 'K' as
First and 'L' as third alphabet?
SQL QUERY
OUTPUT
QUESTION 35 Write SQL command to get the following:
SQL QUERY
OUTPUT
SQL QUERY
OUTPUT
(c) Display the designation-wise list of employees with name, salary, and date
of joining.
SQL QUERY
(d) List the name of employees who are not getting commission.
SQL QUERY
OUTPUT
SQL QUERY
OUTPUT
(f) Display the name of employees along with their designation and department
name.
SQL QUERY
OUTPUT
SQL QUERY
(i) To show details of all PCs with stock more than 110.
SQL QUERY
OUTPUT
(ii) To find the company which gives a warranty of more than 2 years.
SQL QUERY
OUTPUT
(iii) To list stock value of the BPL company where stock value is the sum of the
products of price and stock.
SQL QUERY
OUTPUT
SQL QUERY
OUTPUT
(a) To list the details of furniture whose price is more than 5000:
SQL QUERY
OUTPUT
(b) To list the name and price of furniture where the discount is between 10
and 20:
SQL QUERY
OUTPUT
SQL QUERY
OUTPUT
(d) To list the item names and types of all items whose names start with 'P':
SQL QUERY
OUTPUT
SQL QUERY
SELECT*FROM FURNITURE
WHERE TYPE=’BABYCOT’;
OUTPUT
(i) List the names of those students who have obtained rank 1 sorted by NAME:
SQL QUERY
OUTPUT
(ii) Display a list of all those names whose AVERAGE is greater than 65:
SQL QUERY
OUTPUT
(iii) Display the names of those students who have opted COMPUTER as a
SUBJECT with an AVERAGE of more than 60:
SQL QUERY
OUTPUT
SQL QUERY
OUTPUT
OUTPUT
OUTPUT
QUESTION 38- Answer the questions based on the table given below
SQL QUERY
OUTPUT
(b) To list the names of female patients who are in the ENT department:
SQL QUERY
(c) To list the names of all patients with their date of admission in ascending
order:
SQL QUERY
OUTPUT
(d) To display patient Name, Charges, and Age for only female patients:
SQL QUERY
OUTPUT
(e) Execute the output of the following SQL commands: