Avatar of gudii9
gudii9
Flag for United States of America asked on

max query not working

SELECT Professor_Name, Salary FROM SALARIES WHERE Salary > (SELECT MIN(Salary) FROM SALARIES) * 4;
why above query not working
please advise
DatabasesMicrosoft SQL ServerOracle DatabaseSybase DatabaseSQL

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Raja Jegan R

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Geert G

a query which returns no rows works
a query which gives a syntax error doesn't work

if it didn't work, what error did you get ?
slightwv (䄆 Netminder)

It appears you want anyone making more than 4 times the minimum salary.

Every time you think you need to select from the same table again, especially in an inline query, stop and rethink it.

See if this works for you:
SELECT Professor_Name, Salary from (
	SELECT Professor_Name, Salary, min(salary) over() * 4 four_time_min FROM SALARIES
) salaries
where salary > four_time_min
/

Open in new window


With all the new questions, I understand you are learning SQL.  The WINDOW functions are very powerful once you understand the syntax and what they are doing.

I suggest spending some time in the documentation and other online examples.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes