From: Michael Widenius Date: March 15 1999 6:15pm Subject: Sql Query question List-Archive: http://lists.mysql.com/mysql/275 Message-Id: <14061.19933.845761.51698@monty.pp.sci.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable >>>>> "Graeme" =3D=3D Graeme B Davis writes: Graeme> Basically I am trying to accomplish an if statement in my sql q= uery.=A0 I want to Graeme> do one query Tuesday-Friday and then another query Monday. Graeme> Here are two separate queries: Graeme> Tuesday-Friday: Graeme> --------------- Graeme> select assignedto, count(assignedto) as count from openedstats = where modified <=3D Graeme> DATE_SUB(now(),INTERVAL 2 DAY) group by assignedto order by cou= nt desc; Graeme> Monday query: Graeme> ------------- Graeme> select assignedto, count(assignedto) as count from openedstats = where modified <=3D Graeme> DATE_SUB(now(),INTERVAL 4 DAY) group by assignedto order by cou= nt desc; Graeme> This is all I have come up with so far, but I don't know how to= integrate this Graeme> into the select: mysql> select if(strcmp(dayname(now()),"Monday"),"2","4"); Graeme> +---------------------------------------------+ Graeme> | if(strcmp(dayname(now()),"Monday"),"2","4") | Graeme> +---------------------------------------------+ Graeme> | 4=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | Graeme> +---------------------------------------------+ Graeme> (I did this query on Monday, so it returned "4", which correspo= nds to the above Graeme> queries "INTERVAL X DAY" Graeme> Any hints, ideas? Hi! select assignedto, count(assignedto) as count from openedstats where modified <=3D DATE_SUB(now(),INTERVAL if (weekday(now())=3D0,4,2) days)= group by assignedto order by count desc; Regards, Monty