Is it possible to display day from a query that have parameter date1 and date2.
for example :
SELECT e.struk_no, DATE(e.created_at), c.id,
count(a.harga_jual) as counting,
sum(a.harga_jual) AS total_item
FROM transaction_detail a
LEFT JOIN `transaction` e
ON a.transaction_id = e.id
LEFT JOIN karyawan b
ON a.karyawan_id = b.id
LEFT JOIN list_harga c
ON a.item_id = c.id
LEFT JOIN item_layanan d
ON c.item_layanan_id = d.id
WHERE DATE(e.created_at) BETWEEN DATE('2016-11-13') AND DATE('2016-11-15')
GROUP BY a.karyawan_id, b.nama_karyawan, d.nama_item
I got this :
+----------+--------------------+----+----------+------------+
| struk_no | DATE(e.created_at) | id | counting | total_item |
+----------+--------------------+----+----------+------------+
| 2 | 2016-11-15 | 5 | 1 | 90000 |
| 1 | 2016-11-14 | 4 | 2 | 200000 |
| 4 | 2016-11-15 | 16 | 1 | 400000 |
| 3 | 2016-11-15 | 19 | 1 | 75000 |
+----------+--------------------+----+----------+------------+
4 rows in set
Please see : WHERE DATE(e.created_at) BETWEEN DATE('2016-11-13') AND DATE('2016-11-15')
Is is possible to create like this
+----------+----+----+----+----+----------+------------+
| struk_no | 13 | 14 | 15 | id | counting | total_item |
+----------+----+----+----+----+----------+------------+
| 2 | | | 1 | 5 | 1 | 90000 |
| 1 | | 1 | 1 | 4 | 2 | 200000 |
| 4 | | | 1 | 16 | 1 | 400000 |
| 3 | | | 1 | 19 | 1 | 75000 |
+----------+----+----+----+----+----------+------------+
4 rows in set
The unique parameter is id
, What named case like this?
Thanks all
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…