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

SQL Server Question Paper - 2

Write the following queries using query analyzer 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Display all records Display records who are in "First Class" Display records who got discount greater than 0 Display records who paid admission fee 3000 or 3250 and who got discount 10 Display records who does not allotted class.

Uploaded by

api-3766129
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
258 views3 pages

SQL Server Question Paper - 2

Write the following queries using query analyzer 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Display all records Display records who are in "First Class" Display records who got discount greater than 0 Display records who paid admission fee 3000 or 3250 and who got discount 10 Display records who does not allotted class.

Uploaded by

api-3766129
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

CREATE DATABASE SCHOOL

CREATE TABLE Student


(
StudentID INT Primary Key,
StudentName VARCHAR(100) NOT NULL,
Class VARCHAR(20),
DOJ DATETIME,
AdmissionFee MONEY,
Discount INT
)

INSERT INTO Student


(
StudentID, StudentName, Class, DOJ, AdmissionFee, Discount
)
VALUES
(
1, 'Ritesh', 'First Class','06/12/2005', 3000, 10
)

INSERT INTO Student


(
StudentID, StudentName, Class, DOJ, AdmissionFee, Discount
)
VALUES
(
2, 'Ritesh Agarwal', 'Second Class','06/12/2005', 3250, 0
)

INSERT INTO Student


(
StudentID, StudentName, Class, DOJ, AdmissionFee, Discount
)
VALUES
(
3, 'Abhishek Agarwal', 'First Class','06/12/2005', 3250, 0
)

INSERT INTO Student


(
StudentID, StudentName, Class, DOJ
)
VALUES
(
4, 'Amul', 'First Class','06/12/2005'
)

INSERT INTO Student


(
StudentID, StudentName, DOJ
)
VALUES
(
5, 'Priya', '06/12/2005'
)

Write the following queries using query analyzer

1. Display all records


2. Display all columns and DOJ column should appear as [Date of Joining]
3. Display all columns and add a column with Constant Value “Admitted”
4. Display all columns and also Display today’s date with each row
5. Display records who are in “First Class”
6. Display records who got discount greater than 0
7. Display records who got discount equal to 0 and also Null
8. Display Distinct records who are in First Class, Second Class, Tenth Class
9. Display records student who does not allotted class
10. Display records who joined between ‘06/01/2004’ and ‘06/01/2005’
11. Display records who paid admission fee 3000 or 3250
12. Display records who paid admission fee 3000 or 3250 and who got discount 10

--ANSWERS:-
--1)
SELECT *FROM STUDENT
--2)
SELECT StudentID,StudentName,Class,DOJ AS [Date of
Joining],AdmissionFee,Discount FROM STUDENT
--3)
SELECT StudentID,StudentName,'Admitted',Class,DOJ ,AdmissionFee,Discount
FROM STUDENT
--4)
SELECT StudentID,StudentName,Class,DOJ ,AdmissionFee,Discount,GETDATE()
FROM STUDENT
--5)
SELECT * FROM STUDENT
WHERE Class='First Class'
--6)
SELECT * FROM STUDENT
WHERE Discount>0
--7)
SELECT * FROM STUDENT
WHERE Discount=0 OR Discount IS NULL
--8)
SELECT DISTINCT CLASS FROM STUDENT
--(THERE IS NO TENTH CLASS IN THE TABLE)
--9)
SELECT * FROM STUDENT
WHERE CLASS IS NULL
--10)
SELECT * FROM STUDENT
WHERE DOJ BETWEEN '06-01-2004' AND '06-01-2005'
--11)
SELECT * FROM STUDENT
WHERE AdmissionFee IN(3000,3250)
--12)
SELECT * FROM STUDENT
WHERE AdmissionFee IN(3000,3250) AND Discount=10

You might also like