यदि आपके पास कई वर्ष हैं, तो आपको वर्ष को भी ध्यान में रखना चाहिए। एक तरीका है:
SELECT date_part('year', author_date::date) as year,
date_part('week', author_date::date) AS weekly,
COUNT(author_email)
FROM commits
GROUP BY year, weekly
ORDER BY year, weekly;
इसे लिखने का एक और स्वाभाविक तरीका date_trunc()
. का उपयोग करता है :
SELECT date_trunc('week', author_date::date) AS weekly,
COUNT(author_email)
FROM commits
GROUP BY weekly
ORDER BY weekly;