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

Assignment Part2 DML

The document contains 11 questions asking to write SQL queries on various tables to retrieve information. The questions include getting employee details, counting number of students in certain grade ranges, listing cities by station ID or name characteristics, calculating differences between counts, getting totals and averages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views

Assignment Part2 DML

The document contains 11 questions asking to write SQL queries on various tables to retrieve information. The questions include getting employee details, counting number of students in certain grade ranges, listing cities by station ID or name characteristics, calculating differences between counts, getting totals and averages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

select all employees in department 10 whose salary is greater than


3000. [table: employee]
Syntax;-
use assignment;
select * from employee;
select * from employee where 'deptno=10' and 'salary >3000';

-------------------------------------------------------------------------
2. The grading of students based on the marks they have obtained is done
as follows

40 to 50 -> Second Class


50 to 60 -> First Class
60 to 80 -> First Class
80 to 100 -> Distinctions

* How many students have graduated with first class?


SYNTAX-
use assignment;
SELECT * FROM STUDENTS;
SELECT COUNT('marks')
from students
where marks between '60' and '80';

How many students have obtained distinction? [table: students]


use assignment;
SELECT * FROM STUDENTS;
SELECT COUNT('marks')
from students
where marks between '80' and '100';

-----------------------------------------------------------------------
3. Get a list of city names from station with even ID numbers only.
Exclude duplicates from your answer.[table: station]

4. Find the difference between the total number of city entries in the
table and the number of distinct city entries in the table. In other
words, if N is the number of city entries in station, and N1 is the
number of distinct city names in station, write a query to find the value
of N-N1 from station.[table: station]

5. a. Query the list of CITY names starting with vowels (i.e., a, e, i,


o, or u) from STATION. Your result cannot contain duplicates. [Hint: Use
RIGHT() / LEFT() methods ]
b. Query the list of CITY names from STATION which have vowels (i.e.,
a, e, i, o, and u) as both their first and last characters. Your result
cannot contain duplicates.
c. Query the list of CITY names from STATION that do not start with
vowels. Your result cannot contain duplicates.
d. Query the list of CITY names from STATION that either do not start
with vowels or do not end with vowels. Your result cannot contain
duplicates. [table: station]
7. Write a query that prints a list of employee names having a salary
greater than $2000 per month who have been employed for less than 10
months. Sort your result by ascending emp_id. [table: emp]

8. 12. How much money does the company spend every month on salaries for
each department? [table: emp]

Expected Result:

+-------------+--------+
| sum(salary) | deptno |
+-------------+--------+
| 30700.00 | 10 |
| 13600.00 | 20 |
| 2600.00 | 30 |
+-------------+--------+

9. How many cities in the CITY table have a Population larger than
100000. [table: city]

Syntax -select * from city


-> where population > 100000;

-------------------------------------------------------------------
10. What is the total population of California? [table: city]

11. What is the average population of the districts in each country?


[table: city]

Expected Result:

+-------------+-----------------+
| countrycode | avg(population) |
+-------------+-----------------+
| JPN | 175839.2000 |
| NLD | 593321.0000 |
| USA | 120225.8750 |
+-------------+-----------------+

You might also like