can I make this ?
------------------------
date |total|
2016-01-12 | 1 |
2016-01-13 | 2 |
2016-01-14 | 0 |
2016-01-15 | 1 |
using mysql query ? i was try but my result is
date |total|
2016-01-12 | 1 |
2016-01-13 | 2 |
2016-01-15 | 1 |
myquery just show the date who have a result
this is my query :
select day(tgl_daftar) as tanggal, count(day(tgl_daftar)) as jumlah
from pasien
where month(tgl_daftar) = '06' and year(tgl_daftar) = '2016'
group by day(tgl_daftar)
and this is my table :
Field Type Collation Null Key Default Extra Privileges Comment
-------------------- ----------- ----------------- ------ ------ ------- ------ ------------------------------- -------
NO_PASIEN char(6) latin1_swedish_ci NO PRI (NULL) select,insert,update,references
ID_KOTA int(11) (NULL) NO MUL (NULL) select,insert,update,references
ID_AGAMA int(11) (NULL) NO MUL (NULL) select,insert,update,references
ID_PEKERJAAN int(11) (NULL) NO MUL (NULL) select,insert,update,references
NAMA_PASIEN varchar(30) latin1_swedish_ci YES (NULL) select,insert,update,references
JENIS_KELAMIN_PASIEN char(2) latin1_swedish_ci YES (NULL) select,insert,update,references
TGLLAHIR_PASIEN date (NULL) YES (NULL) select,insert,update,references
NO_TELPON_PAS int(11) (NULL) YES (NULL) select,insert,update,references
ALAMAT_PASIEN varchar(50) latin1_swedish_ci YES (NULL) select,insert,update,references
TGL_DAFTAR date (NULL) YES (NULL) select,insert,update,references
any ideas.?
try this in your query,
SELECT
`date`, SUM(<somefield>) AS `total`
FROM
<your_table>
GROUP BY
`date`
HAVING
`total` > 0;
your query,
SELECT
DAY(tgl_daftar) AS tanggal,
COUNT(day(tgl_daftar)) AS jumlah
FROM
pasien
WHERE
MONTH(tgl_daftar) = '06' AND YEAR(tgl_daftar) = '2016'
GROUP BY
DAY(tgl_daftar)
HAVING
`jumlah` > 0;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.