Basically I am trying to accomplish an if statement in my sql query. I want to
do one query Tuesday-Friday and then another query Monday.
Here are two separate queries:
Tuesday-Friday:
---------------
select assignedto, count(assignedto) as count from openedstats where modified <=
DATE_SUB(now(),INTERVAL 2 DAY) group by assignedto order by count desc;
Monday query:
-------------
select assignedto, count(assignedto) as count from openedstats where modified <=
DATE_SUB(now(),INTERVAL 4 DAY) group by assignedto order by count desc;
This is all I have come up with so far, but I don't know how to integrate this
into the select:
mysql> select if(strcmp(dayname(now()),"Monday"),"2","4");
+---------------------------------------------+
| if(strcmp(dayname(now()),"Monday"),"2","4") |
+---------------------------------------------+
|
4
|
+---------------------------------------------+
(I did this query on Monday, so it returned "4", which corresponds to the above
queries "INTERVAL X DAY"
Any hints, ideas?
Thanks!
| Thread |
|---|
| • Sql Query question | Graeme B. Davis | 15 Mar |
| • Sql Query question | Michael Widenius | 15 Mar |