Sie sind auf Seite 1von 3

(Q1) SQL Queries.

(Simple) [10 Marks]

1. Display all Employees records where “FirstName” equals to “bob”.

2. Display first 10 records Orders where city in “KHI” and “LHR.

3. Display non-repeating cities from Orders except city “KHI” and “LHR.

4. Display all Student records where registration occurs from ‘1/1/2015’ till ‘6/6/2015’.

(MM/DD/YY). Using “BETWEEN” operator.

5. Select maximum, minimum, average salaries from “Employees”.

6. Show first three (3) products with highest price.

7. Count number of Student Gender-wise.

8. Insert a record in emp (id, name, phone, salary) table.

9. Delete all records from “attendance” table where “Status” equals to “absent”.

10. Update salaries of employees with 10% increment.

(Q2) SQL Queries. (Simple) [10 Marks]

1. Display all information from table: World

2. List down population of World in descending order.

3. Display Largest population of the world

4. List of countries and population from Asian continent (value: ‘Asia’)

5. List of countries that contain word ‘tan’.

6. Show the country and population for countries EXCEPT France, Germany, Italy

7. Show average marks in course id (cid) = 1 for all students.

8. Show number of total students (with no repetition) in table exam.

9. List down all student whose exam was held 6 months back.

10. Display all exam results with cgpa (4 and 3.5)


(Q3) SQL Queries. (Simple) [10 Marks]

1. Display all records from “Emp” table where “ename” equals to “bob”.

2. Display first 10 records from “orders” table where city in “KHI” and “LHR” using

Boolean operators.

3. Display non-repeating cities from “orders” table except city “KHI” and “LHR” using

“IN” operator.

4. Display all records from “stud” table where registration occurs from ‘1/1/2015’ till

‘6/6/2015’ (MM/DD/YY). Using “BETWEEN” operator.

5. Select maximum, minimum, average salaries.

6. Show first three (3) products with highest price.

7. Count number of student Gender-wise.

8. Insert a record in emp (id, ename, phone, salary) table.

9. Delete all records from “attendance” table where “status” equals to “absent”.

10. Update salaries of employees with 10% increment.

(Q4) (Simple) SQL Queries. (with proper aliasing) [05 Marks]

Schema:

Student (sid, first Name, lastName, DOB, Gender)

Course (cid, Cname, CreditHours, CourseFee)

Exam (sid, cid, marks, eDate)

1. Write a query to display ‘Hello World’;

2. Display all student records

3. Display first 100 student records.

4. Display all courses with three credit hours and course fee not more than 13000.

5. Show records where marks are not given yet.

6. Enlist all students’ records where first Name starts with ‘a’ or ‘w’.

7. Show top 3 students with highest marks.

8. Delete all records from “Exam” conducted on ‘Mar 14 2016’.

9. Insert a record in “Student” table.


10. Calculate student age from DOB.

Schema to solve above Queries.

 World (id, country, continent, area, population)


 Exam (exid, sid, cid, date, marks, cgpa)
 Employees (EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate,
 HireDate, Address, City, Region, Country, HomePhone, Extension, Photo, Notes,
 ReportsTo, Salary)
 Products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice,
 UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued)
 Customers (CustomerID, CompanyName, ContactName, ContactTitle, Address, City,
 Region, PostalCode, Country, Phone, Fax)
 Orders (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate,
 ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode,
 ShipCountry)
 [Order Details] (OrderID, ProductID, UnitPrice, Quantity, Discount)
 Attendance (Studid, CourseId, Date, Status {Present, Absent})
 Course (CourseId, CourseName, Fees)
 Student (StudId, Name, Contact, Age, Gender, RegDate)
 Exam (exid, sid, cid, date, marks, cgpa)

Das könnte Ihnen auch gefallen