I hope the formatting works on this post!!
(question at bottom!)
Thanks in advance,
Edward
Table structure:
mysql> desc Log;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| date | varchar(20) | | | | |
| action | varchar(30) | | | | |
| detail | varchar(150) | | | | |
+--------+--------------+------+-----+---------+-------+
Data:
mysql> select * from Log limit 10;
+------------+-------------------+--------------+
| date | action | detail |
+------------+-------------------+--------------+
| 2004-06-21 | TechError | some detail |
| 2004-06-21 | EditAction | some detail |
| 2004-06-21 | TechError | some detail |
| 2004-06-20 | CancelAction | some detail |
| 2004-06-20 | TechError | some detail |
| 2004-06-20 | EditAction | some detail |
| 2004-06-19 | TechError | some detail |
| 2004-06-19 | TechError | some detail |
| 2004-06-19 | CancelAction | some detail |
| 2004-06-19 | TechError | some detail |
+------------+-------------------+--------------+
10 rows in set (0.00 sec)
mysql> select date, sum(case when action="TechError" then 1 else 0 end)
from Log
where date > '(current_date - 3)'
group by date
order by date asc;
+------------+-----------------------------------------------------+
| date | sum(case when action="TechError" then 1 else 0 end) |
+------------+-----------------------------------------------------+
| 2004-05-19 | 3 |
| 2004-05-20 | 1 |
| 2004-05-21 | 2 |
+------------------------------------------------------------------+
How do I write a query to return:
+------------+-----------+------------+--------------+
| date | TechError | EditAction | CancelAction |
+------------+-----------+------------+--------------+
| 2004-05-19 | 3 | 0 | 1 |
| 2004-05-20 | 1 | 1 | 1 |
| 2004-05-21 | 2 | 1 | 0 |
+------------+-----------+------------+--------------+
???
(question at bottom!)
Thanks in advance,
Edward
Table structure:
mysql> desc Log;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| date | varchar(20) | | | | |
| action | varchar(30) | | | | |
| detail | varchar(150) | | | | |
+--------+--------------+------+-----+---------+-------+
Data:
mysql> select * from Log limit 10;
+------------+-------------------+--------------+
| date | action | detail |
+------------+-------------------+--------------+
| 2004-06-21 | TechError | some detail |
| 2004-06-21 | EditAction | some detail |
| 2004-06-21 | TechError | some detail |
| 2004-06-20 | CancelAction | some detail |
| 2004-06-20 | TechError | some detail |
| 2004-06-20 | EditAction | some detail |
| 2004-06-19 | TechError | some detail |
| 2004-06-19 | TechError | some detail |
| 2004-06-19 | CancelAction | some detail |
| 2004-06-19 | TechError | some detail |
+------------+-------------------+--------------+
10 rows in set (0.00 sec)
mysql> select date, sum(case when action="TechError" then 1 else 0 end)
from Log
where date > '(current_date - 3)'
group by date
order by date asc;
+------------+-----------------------------------------------------+
| date | sum(case when action="TechError" then 1 else 0 end) |
+------------+-----------------------------------------------------+
| 2004-05-19 | 3 |
| 2004-05-20 | 1 |
| 2004-05-21 | 2 |
+------------------------------------------------------------------+
How do I write a query to return:
+------------+-----------+------------+--------------+
| date | TechError | EditAction | CancelAction |
+------------+-----------+------------+--------------+
| 2004-05-19 | 3 | 0 | 1 |
| 2004-05-20 | 1 | 1 | 1 |
| 2004-05-21 | 2 | 1 | 0 |
+------------+-----------+------------+--------------+
???