Sie sind auf Seite 1von 3

Table : Store

StoreId Name Location City NoOfEmployees DateOpened SalesAmount


S101 Planetfashion KarolBagh Delhi 7 2015-10-16 300000
S102 Trends Nehru Mumbai 11 2015-08-09 400000
Nagar
S103 Vogue Vikas Delhi 10 2015-06-27 200000
Vihar
S104 Superfashion Defence Delhi 8 2015-02-18 450000
Colony
S105 Rage Bandra Mumbai 5 2015-09-22 600000
(i) To display name, location, city, SalesAmount of stores in
descending order of SalesAmount.
(ii) To display names of stores along with SalesAmount of those
stores that have ‘fashion’ anywhere in their store names.
(iii) To display Stores names, Location and Date Opened of st res
st
that were opened before 1 March, 2015.
(iv) To display total SalesAmount of each city along with city name.
(v) SELECT distinct city FROM store;
(vi) SELECT Name, length (name), left (na e, 3) FROM
Store where NoOfEmployees<3;

Consider the Table ‘‘Infant’’ shown below :


Table : Infant
ItemCode Item DatePurchase UnitPrice Discount
101 Frock 2016-01-23 700 10
102 Cot 2015-09-23 5000 25
103 Soft Toy 2016-06-17 800 10
104 Baby Socks 2014-10-16 100 7
105 Baby Suit 2015-09-20 500 5

Note : Discount column stores discount %.


Write the commands in SQL for (i) to (viii) and output for (ix) and (x).
(i) To display the details about the Cot. 1
(ii) To list the names of items and their unit price that have unit price
less than 800 and discount more than 5%. 1
(iii) To list the names of items and their date of purchase that were
st
purchased after 31 December, 2015. 1
(iv) To display the number of items that have more than 10% as discount. 1
(v) To display item code and unit price in decreasing order of unit price. 1
(vi) To increase the unit price of each item by 10% of their unit price. 1

(vii) To display the highest unit price of items. 1

(viii) To display the names of items that have ‘Baby’ anywhere in their
item names. 1

(ix) SELECT MID (Item,1,2) FROM Infant; 1

(x) SELECT AVG(UnitPrice) FROM Infant WHERE DATEPURCHASE


>‘2015–01–01’; 1
(Table : Salesperson)

SID Name Phone DOB Salary Area

S101 Amit Kumar 98101789654 1967-01-23 67000.00 North

S102 Deepika Sharma 99104567834 1992-09-23 32000.00 South

S103 Vinay Srivastav 98101546789 1991-06-27 35000.00 North

S104 Kumar Mehta 88675345789 1967-10-16 40000.00 East

S105 Rashmi Kumar 98101567434 1972-09-20 50000.00 South

Note : Columns SID and DOB contain Sales Person Id and Data of Birth
respectively.
(i)Write the data types of SID and DOB columns. 1
(ii) Display names of Salespersons and their Salaries who have salaries in the
range 30000.00 to 40000.00 1
(iii) To list Names, Phone numbers and DOB (Date of Birth) of Salespersons
st
who were born before 1 November, 1992. 1
(iv) To display Names and Salaries of Salespersons in descending order of
salary. 1
(v) To display areas in which Salespersons are working. Duplicate Areas
should not be displayed. 1
(vi) To display SID, Names along with Salaries increased by 500. (Increase of
` 500 is only to be displayed and not to be updated in the table) 1
(vii) To display Area along with number of Salespersons working in that area. 1
(viii) To display Names of Salespersons who have the word ‘Kumar’ anywhere
in their names. 1
(ix) SELECT Name, LENGTH(Name) FROM Salesperson; 1
(x) SELECT Area, COUNT (*) 1
FROM Salesperson
GROUP BY Area
HAVING COUNT (*) > 1;

Das könnte Ihnen auch gefallen