List:General Discussion« Previous MessageNext Message »
From:William Newton Date:June 10 2008 3:30pm
Subject:Fw: mysql query, min, max with where conditions
View as plain text  


Well, if your particular problem has a well defined maximum minimum and minimum maximum
(Ie the max(q) < 4294967296, because q is a 32 bit  unsigned int, and min(q)> -1) 
then you can do it without any extra joins or sub selects.

select
a,
b,
min(IF(date <100, q, 4294967296)) as min_q,
max(IF(date>100, q, -1)) as min_q,
from a left join b left join c
group by a.p



----- Original Message ----
From: "CRISTEA, Adrian" <adrian@stripped>
To: mysql@stripped
Sent: Monday, June 9, 2008 9:33:37 AM
Subject: mysql query, min, max with where conditions 

Hello there,

What is the corect syntax for selecting something like:

select
a,
b,
(min(q) where date<100),
(max(q) where date>100)
from a left join b left join c
group by a.p

i need min() max() values each of them with other WHERE clause.

How can I do that?

Adrian.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=1


      
Thread
Fw: mysql query, min, max with where conditionsWilliam Newton10 Jun