Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MAX and MIN functions combined

Author  Topic 

sh0wtym3
Starting Member

9 Posts

Posted - 2010-04-30 : 11:16:58
How would I get both the minimum AND maximum values of a particular column? I tried the following which doesn't seem to work:


SELECT MAX(prod_price) AS max_price,
MIN(prod_price) AS min_price,
FROM Products


I'm getting a syntax error but I can't figure out why

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-30 : 11:32:25
remove the last comma...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sh0wtym3
Starting Member

9 Posts

Posted - 2010-04-30 : 11:39:20
I feel like an idiot now. Thanks for answering
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-01 : 09:34:56
You are not an idiot.
All of us have made this kind of mistake again and again


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-07 : 09:37:10
quote:
Originally posted by sh0wtym3

How would I get both the minimum AND maximum values of a particular column? I tried the following which doesn't seem to work:


SELECT MAX(prod_price) AS max_price,
MIN(prod_price) AS min_price,
FROM Products


I'm getting a syntax error but I can't figure out why


Next time you get an error, double click that error
It will point to the line where there is a mistake

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -