There is a table employee with the following columns
fname : employee first name
minit : employee middle initial
lname : Employee last name
ssn : social security number
bdate : date of birth of the employee
address : address of the employee
sex : gender of the employee
salary : annual salary of the employee
super_ssn : social security number of the supervisor of the employee
dno : department number of the employee
Write a query to find the social security numbers of all employees who are either male or have salary less than 30000. Order the results on the basis of social security number in ascending order. Please note that the gender is denoted by either F or M.
Consider two tables employee and dependent containing the columns as given below.
ssn: social security number
dno: departmnt number of employee
essn: ssn for employee
dependent_name: dependent name
perform a query to determine the name of all dependents of the employees of department number 10? Order the results by the name of dependents.
Method 2 Using join operation
employee having the following columns
There is a table named salary containing the details of salaries of employees in an organisation along with their department names.
Suppose you have a table marks following columns
Write a query to determine the spread of the marks of the student having average marks greater than the overall average. Alias the column as Spread. Spread is defined as the difference between the highest and lowest marks obtained by the student. Order the output in order of student id.
select student_id, (max(marks)-min(marks) ) as Spread
from student group by student_id order by student_id