0% found this document useful (0 votes)
5 views3 pages

SQL Queries for Employee and Student Tables

The document contains SQL queries for three tables: Emp, Student, and Item. It includes various operations such as displaying, inserting, updating, and selecting records based on specific conditions. Each query is provided with a corresponding answer for clarity.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

SQL Queries for Employee and Student Tables

The document contains SQL queries for three tables: Emp, Student, and Item. It includes various operations such as displaying, inserting, updating, and selecting records based on specific conditions. Each query is provided with a corresponding answer for clarity.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL QUERIES

Write the queries for the following table : Emp

a. Display the salary of all the employees after incrementing by Rs 1000.


Ans. Select Salary +1000 from Emp;
b. Display the Employee id and salary of all the employees after decreasing by Rs 500.
Ans. Select Emp_id, Salary – 500 from Emp;

c. Display the Name and salary of all the employees after incrementing it as thrice the amount of
present salary.
Ans. Select Ename, Salary * 3 from Emp;
d. Display the Employee id, Name and salary of all the employees after decrementing it as half the
amount of present salary.
Ans. Select Emp_id, Ename, Salary/2 from Emp;
e. Display the Employee id and Name of all the employees.
Ans. Select Emp_id, Ename from Emp;

Write the queries for the following table : Student

a. Display the entire table


Ans. Select * from Student

b. Display the list of students whose house color is blue.


Ans. Select * from Student where House = “Blue”
c. Display the admission number of students whose house color is green.
Ans. Select Admno from Student where House = “Yellow”

d. To view records in ascending order of Admission Number.


Ans. Select * from Student order by Admno Asc;

e. Display the records of Class 10 Students.


Ans. Select * from students where Class = 10;

f. Display the class of ‘Ravi’


Ans. Select Class from Student where Name = ‘Ravi’

g. Insert the given record : 1004, “Aman”, 11, “Blue”


Ans. Insert into Student values( 1004, “Aman”, 11, “Blue”)

a. Write a query to insert a new record of following details

15, “Pencil”, 20, 10

Ans. Insert into Item values(15, “Pencil”, 20, 10)


b. Write a query to display detail of items whose quantity is more than 10.
Ans. Select * from Item where Qty > 10
c. Write a query to change the quantity of Item number 13 to 25.

Ans. Update Item set Qty = 25 where Itemno = 13

d. Display the total amount of each item. The amount must be calculated as the price multiplied by
quantity for each item
Ans. Select Price * Qty from Item.

e. Display the name of item whose price is 10.


Ans. Select Iname from Item where price = 10

f. Display all the records in ascending order of price.


Ans. Select * from Item order by Price asc.
i. Write a query to increase the price of all items by Rs2.
Ans. Update Item set Price = Price + 2;

j. Write a query to decrease the price of all items by Rs2 whose price is less than 20.
Ans. Update Item set Price = Price – 2 where Price < 20;

You might also like