0% found this document useful (0 votes)
25 views

DBMS Query Questions.

Uploaded by

akshay kamble
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

DBMS Query Questions.

Uploaded by

akshay kamble
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q.

Write the queries for the following table : Emp

Emp_id Ename Salary

1 Suman 20000

2 Sanjay 32000

3 Ravi 30000
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;

Q. Write the queries for the following table : Item

Itemno Iname Price Qty

12 Pen 10 17

13 Eraser 5 15

14 Notebook 15 20

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.

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


Ans. Select * from Item order by Price asc.

g. Identify the Primary key from table Item.


Ans. Itemno

h. Write the suitable data type of field “Iname”.


Ans. Char or Varchar

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;

Consider the following table: Sales


Sale_Id Prod_Name Price Discount

1101 Laptop 65000 2500

1103 Pen tab 29500 1000

1105 Desktop 50000 1550

1106 Printer 12000 2000

1. How many fields and records are there in Sales table?


Answer:Four fields and four records are there in table Sales.

2. Write SQL commands for the following:

i. Display Sales ID and price of all products whose discount is more than
1000.
Answer: select Sale_Id, Price from Sales where Discount > 1000;

ii. Display the details alphabetically by product name.


Answer: select * from Sales order by Prod_Name;

iii. Display product name and sales price after deducting the discount from the
price.
Note: Sales price can be calculated as (price-discount)
Answer: select Prod_Name, Price- Discount from Sales;

You might also like