SELECT
DATE_FORMAT(
DATE_ADD(
CAST(
CONCAT( YEAR ( NOW( ) ), '-01-01' ) AS date
),
INTERVAL t500.id - 1 DAY
),
'%w'
),
count(*) as days
FROM
t500
WHERE
t500.id < DATEDIFF(
CAST(
CONCAT(
YEAR ( NOW( ) ) + 1,
'-01-01'
) AS date
),
CAST(
CONCAT( YEAR ( NOW( ) ), '-01-01' ) AS date
)
)
GROUP BY
DATE_FORMAT(
DATE_ADD(
CAST(
CONCAT( YEAR ( NOW( ) ), '-01-01' ) AS date
),
INTERVAL t500.id - 1 DAY
),
'%w'
)
转载于:https://my.oschina.net/u/3238650/blog/3020350