StudentRik
StudentRik

Reputation: 1049

SQL Functions using MIN and MAX together

I am trying to get 2 pieces of information from a database by using the MIN and MAX function. This is my statement:

Select MIN(SAL) AND MAX(SAL) From EMP;

I just cannot get the result, I get an error saying From keyword not found where expected.

Thank you

Upvotes: 2

Views: 4173

Answers (1)

Mark Byers
Mark Byers

Reputation: 838156

Use a comma instead of AND:

Select MIN(SAL), MAX(SAL) From EMP

You might also want to consider giving your columns aliases:

SELECT
   MIN(SAL) AS min_sal,
   MAX(SAL) AS max_sal
FROM EMP

Upvotes: 5

Related Questions