SQL ORACLE Sub query. need to fix my outcomes -


i have database thousands of data. name of table person11

i need select concatenated name, jobtitle , salary of people have cat value of n , salary @ least 30 percent higher average salary of people jobtitle , cat value of n. 3 column headings should name, jobtitle , salary. rows should sorted in traditional phonebook order.

so far code:

select initcap(fname || ' ' || lname) name,    initcap(jobtitle) jobtitle, salary person11  upper(cat) = 'n'  , salary >= 1.30 * (    select avg(salary)   person11   upper(cat) = 'n') order upper(lname), upper(fname); 

this gives me output of people 30 percent higher average salary cat value of n.

how can find of people 30 percent higher average salary of people job title , has cat value of 'n'?

you need add codition jobtitle:

select initcap(fname || ' ' || lname) name,    initcap(jobtitle) jobtitle, salary person11 p upper(cat) = 'n'  , salary >= 1.30 * (    select avg(salary)   person11   upper(cat) = 'n' , jobtitle = p.jobtitle) order upper(lname), upper(fname); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -