我想問一下關於SQL Server 2005與其他總計字段的日期分組。SQL日期分組
| tanggal | nama | qty |
|---------------------|-------------------------|------|
| 2017-07-11 06:25:00 | APEL | 4.00 |
| 2017-07-11 06:25:00 | SUSU KENTAL MANIS PUTIH | 4.00 |
| 2017-07-11 06:29:00 | APEL | 4.00 |
| 2017-07-11 06:29:00 | SUSU KENTAL MANIS PUTIH | 4.00 |
| 2017-07-10 06:29:00 | APEL | 2.00 |
| 2017-07-10 06:29:00 | SUSU KENTAL MANIS PUTIH | 2.00 |
| 2017-07-11 00:00:00 | APEL | 1.00 |
| 2017-07-11 00:00:00 | SUSU KENTAL MANIS PUTIH | 1.00 |
,我需要得到這樣的
| Tanggal | Barang | Jumlah |
|------------|-------------------------|--------|
| 2017-07-10 | APEL | 2.00 |
| 2017-07-10 | SUSU KENTAL MANIS PUTIH | 2.00 |
| 2017-07-11 | APEL | 9.00 |
| 2017-07-11 | SUSU KENTAL MANIS PUTIH | 9.00 |
下面的代碼
select j.tanggal [Tanggal],p.nama [Barang],sum(p.qty) [Jumlah]
from proses p
left join jual j on j.kode=p.kode
group by j.tanggal,p.kodeItem,p.nama,p.unit,p.kode
THX的答案,但它需要GROUP BY的Cuz總和( p.qty) – Davis