Skip to main content

Write a query that prints a list of employee names for employees in Employee having a salary greater than 2000

 Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than 2000 per month who have been employees for less than 10 months. Sort your result by ascending employee_id.

Input Format

The Employee table containing employee data for a company is described as follows:

ColumnType
employee_idInteger
nameString
monthsInteger
salaryInteger

where employee_id is an employee’s ID number, name is their name, months is the total number of months they’ve been working for the company, and salary is the their monthly salary.

Sample Input

employee_idnamemonthssalary
12228Rose151968
33645Angela13443
45692Frank171608
56118Patrick71345
59725Lisa112330
74197Kimberly164372
78454Bonnie81771
83565Michael62017
98607Todd53396
99989Joe93573

Sample Output

Angela
Michael
Todd
Joe

Explanation

Angela has been an employee for 1 month and earns 3443 per month.
Michael has been an employee for 6 months and earns 2017 per month.
Todd has been an employee for 5 months and earns 3396 per month.
Joe has been an employee for 9 months and earns 3573 per month.
We order our output by ascending employee_id.

MYSQL

select name from employee
where salary > 2000 and months <10
order By employee_id;


Comments

Post a Comment

Popular posts from this blog

Select Names from table which have vowels

  Problem Query the list of  CITY  names from  table  which have vowels (i.e.,  a ,  e ,  i ,  o , and  u ) as both their first  and  last characters. Your result cannot contain duplicates. Input Format The  STATION  table is described as follows: Field Type ID NUMBER CITY VARCHAR2(21) STATE VARCHAR2(2) LAT_N NUMBER LONG_W NUMBER STATION where  LAT_N  is the northern latitude and  LONG_W  is the western longitude. MYSQL select distinct city from station where (city like 'a%' or city like 'e%' or city like 'i%' or city like 'o%' or city like 'u%' ) and ( city like '%a' or city like '%e' or city like '%i' or city like '%o' or city like '%u' )
Q- What will be the result of the query below? Explain your answer and provide a version that behaves correctly. select case when null = null then 'Yup' else 'Nope' end as Result; Ans-This query will actually yield “Nope”, seeming to imply that  null  is not equal to itself! The reason for this is that the proper way to compare a value to  null  in SQL is with the  is  operator, not with  = . Accordingly, the correct version of the above query that yields the expected result (i.e., “Yup”) would be as follows: select case when null is null then 'Yup' else 'Nope' end as Result;