I have a table with the below structure
+------------+--------+------------------+-----+
| E_DATE | CLIENT | TIME | INS |
+------------+--------+------------------+-----+
| 2015-06-04 | comA | 0.00478515625 | a1 |
| 2015-06-04 | comA | 0.0025390625 | a1 |
| 2015-06-04 | comA | 0.0 | a1 |
| 2015-06-04 | comA | 0.0 | a1 |
| 2015-06-04 | comB | 0.0115234375 | a2 |
| 2015-06-04 | comB | 1.953125E-4 | a2 |
| 2015-06-04 | comB | 0.0103515625 | a3 |
| 2015-06-04 | comB | 0.0 | a3 |
| 2015-06-05 | comA | 0.00478515625 | a4 |
| 2015-06-05 | comA | 0.0025390625 | a4 |
| 2015-06-05 | comA | 0.0 | a1 |
| 2015-06-05 | comA | 0.0 | a2 |
| 2015-06-05 | comB | 0.010351 | a1 |
| 2015-06-05 | comB | 0.05625 | a1 |
+------------+--------+------------------+-----+
I am looking to get the following output -
+------------+--------+-----+-----------------------------------------------------------+
| E_DATE | CLIENT | INS | TOTAL_TIME |
+------------+--------+-----+-----------------------------------------------------------+
| 2015-06-04 | comA | a1 | SUM of TIME for a1 for comA for the date in 'E_DATE' column |
| 2015-06-04 | comB | a2 | SUM of TIME for a2 for comA for the date in 'E_DATE' column |
| 2015-06-04 | comB | a3 | SUM of TIME for a3 for comA for the date in 'E_DATE' column |
| 2015-06-05 | comA | a1 | SUM of TIME for a1 for comA for the date in 'E_DATE' column |
| 2015-06-05 | comA | a2 | SUM of TIME for a2 for comA for the date in 'E_DATE' column |
| 2015-06-05 | comA | a4 | SUM of TIME for a2 for comA for the date in 'E_DATE' column |
| 2015-06-05 | comB | a1 | SUM of TIME for a1 for comA for the date in 'E_DATE' column |
+------------+--------+-----+-----------------------------------------------------------+
Is this the right query to achieve this?
select E_DATE, CLIENT,INS,SUM(INS) AS TOTAL_TIME GROUP BY E_DATE,CLIENT
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…