{"id":163,"date":"2018-06-01T08:50:12","date_gmt":"2018-06-01T08:50:12","guid":{"rendered":"http:\/\/uysalyilmaz.com\/?p=163"},"modified":"2026-08-14T13:19:21","modified_gmt":"2026-08-14T13:19:21","slug":"group-by-day-ornekleri-ile","status":"publish","type":"post","link":"http:\/\/uysalyilmaz.com\/index.php\/2018\/06\/01\/group-by-day-ornekleri-ile\/","title":{"rendered":"Group by Day \u2013 \u00d6rnekleri ile"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Grouping By Day Of month:<\/strong><br>\nIn order to group the data by day you can use sql server in built DAY() funtion.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Grouping By Day Of week:<\/strong><br>\nFor this you can use DATEPART(weekday,[date column])<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Grouping By week:<\/strong><br>\nFor this you can use DATEPART(week,[date column])<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Grouping By DAY of Year:<\/strong><br>\nFor this you can use DATEPART(dayofyear,[date column])<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u00d6rnek:<\/strong><\/h3>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;sql&quot;,&quot;mime&quot;:&quot;text\/x-sql&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;SQL&quot;,&quot;language&quot;:&quot;SQL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;sql&quot;}\">CREATE TABLE #Sales\n(\n    Name VARCHAR (100),\n    SalesDateTime DATETIME     \n)\n \n \nGO\nINSERT INTO #Sales\nSELECT 'Product1',\n       '2012-04-01 00:00:00.000'\nUNION ALL\nSELECT 'Product2',\n       '2012-04-02 00:00:00.000'\nUNION ALL\nSELECT 'Product3',\n       '2012-04-02 00:00:00.000'\nUNION ALL\nSELECT 'Product4',\n       '2012-04-03 00:00:00.000'\nUNION ALL\nSELECT 'Product5',\n       '2012-04-03 00:00:00.000'\nUNION ALL\nSELECT 'Product1',\n       '2012-04-30 00:00:00.000'\nUNION ALL\nSELECT 'Product1',\n       '2012-04-30 00:00:00.000'\nUNION ALL\nSELECT 'Product1',\n       '2012-05-02 00:00:00.000'\nUNION ALL\nSELECT 'Product5',\n       '2012-05-02 00:00:00.000'\nUNION ALL\nSELECT 'Product5',\n       '2012-05-02 00:00:00.000'\n \n \nGO\n--GROUP BY DAY of Month\nSELECT   count(*) AS SalesCount, DAY(SalesDateTime) Day\nFROM #Sales\nGROUP BY DAY(SalesDateTime)\n \n--GROUP BY DAY of Week\nSELECT   count(*) AS SalesCount, DATEPART(weekday,SalesDateTime) Day\nFROM #Sales\nGROUP BY DATEPART(weekday,SalesDateTime)\n \n--GROUP BY Week\nSELECT   count(*) AS SalesCount, DATEPART(week,SalesDateTime) Day\nFROM #Sales\nGROUP BY DATEPART(week,SalesDateTime)\n \n--GROUP BY DAY of Year\nSELECT   count(*) AS SalesCount, DATEPART(dayofyear,SalesDateTime) Day\nFROM #Sales\nGROUP BY DATEPART(dayofyear,SalesDateTime)\n \nGO \nDROP TABLE #Sales<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/sqlserverlearner.com\/2012\/group-by-day-with-examples\" target=\"_blank\" rel=\"noopener\">Kaynak<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grouping By Day Of month: In order to group the data by day you can use sql server in built DAY() funtion. Grouping By Day Of week: For this you can use DATEPART(weekday,[date column]) Grouping By week: For this you can use DATEPART(week,[date column]) Grouping By DAY of Year: For this you can use DATEPART(dayofyear,[date [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-t-sql"],"_links":{"self":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":5,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":186,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts\/163\/revisions\/186"}],"wp:attachment":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}