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
 Problem with WHERE clause

Author  Topic 

pappandin
Starting Member

9 Posts

Posted - 2011-11-08 : 03:12:26
I was using this:

SELECT temperatur as maxtemp, dato as maxtempdato
FROM `observasjoner`
WHERE temperatur=(select max(temperatur) from observasjoner) and DATE_FORMAT(dato, '%v-%x') = colname

to show the max temperature ( its in norwegian, but you understand it).

But if i change the MAX to MIN the output is nothing.

Any ideas?

If I use MAX the output is like this

12 2011-10-19

but if I use MIN nothing will show

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 03:20:38
is this sql server? DATE_FORMAT is not a function available in sql server. i think you're using MySQL

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pappandin
Starting Member

9 Posts

Posted - 2011-11-08 : 03:24:07
I can do it by making smaller and less complicated sql-commands, but it would've been better if i had one recordset; for the tidyness
Go to Top of Page

pappandin
Starting Member

9 Posts

Posted - 2011-11-08 : 03:29:54
I'm sorry, im using MySQL at this moment yes, but do you know any similar function? Just downloaded Mysql, thought they used the same functions.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 03:36:00
quote:
Originally posted by pappandin

I'm sorry, im using MySQL at this moment yes, but do you know any similar function? Just downloaded Mysql, thought they used the same functions.


similar function for what?
Your question is not clear
whats it that you're trying to solve?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

pappandin
Starting Member

9 Posts

Posted - 2011-11-08 : 03:40:12
I want to show the min. temperature from a week
DATE_FORMAT(dato, '%v-%x') is the function in MySQL, is there a similar one on SQL?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 03:48:33
quote:
Originally posted by pappandin

I want to show the min. temperature from a week
DATE_FORMAT(dato, '%v-%x') is the function in MySQL, is there a similar one on SQL?


yep...there's CONVERT
but formatting shouldbe done only at front end. no need to do this in t-sql query

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -