SELECT SUM(CASE WHEN MONTH('date') = MONTH(NOW()) THEN sum END) AS 'monthsum',
SUM(CASE WHEN WEEK('date', 1) = WEEK(NOW(), 1) THEN sum END) AS 'weeksum',
SUM(CASE WHEN DATE_FORMAT(date, '%Y-%m-%d') = CURDATE() THEN sum END) AS 'daysum'
FROM bills
WHERE YEAR('date') = YEAR(NOW());
$(document).ready(function(){
$("#submit").click(function(){
$.post('UniqID.php', function(data){
var json = $.parseJSON(data);
$("#a").html(json.номер_купона);
$("#b").html(json.время_действия_купона);
});
});
});