Here is the SQL question: HOW MANY TOTAL SALES ARE COMPLETED EACH MONTH? If I replace 1 with salesdt, then the output wi
Posted: Mon Jul 11, 2022 9:49 am
Here is the SQL question: HOW MANY TOTAL SALES ARECOMPLETED EACH MONTH?
If I replace 1 with salesdt, then the outputwill change:
Sales will be counted separately and won't aggregate bymonth? Can someone explain here, since date_trunc onlycaptures month?It shouldn't have any effect on source column salesdt, nor does itaffect the aggregation of the output? I will upvote you if youcan answer in detail, not just in a few sentences. Thanks.
salesdt descr cost prc The date that the particular sales occurred A description of the item sold. The cost of the item (in cents). The price of the item (in cents).
date_trunc('month', salesdt), sum (prc) from sp.mast group by 1 order by 1 line 10, column 1, location 18 date_trunc 1 2013-01-01 00:00:00+00 2 2013-02-01 00:00:00+00 3 2013-03-01 00:00:00+00 4 2013-04-01 00:00:00+00 sum 9583179 12830204 17783417 20399001
Select date_trunc('month', salesdt), sum (prc) from sp.mast group by salesdt order by salesdt G line 19, column 1, location 36 date_trunc 1 2013-01-01 00:00:00+00 2 2013-01-01 00:00:00+00 3 2013-01-01 00:00:00+00 sum 215955 108301 91318
If I replace 1 with salesdt, then the outputwill change:
Sales will be counted separately and won't aggregate bymonth? Can someone explain here, since date_trunc onlycaptures month?It shouldn't have any effect on source column salesdt, nor does itaffect the aggregation of the output? I will upvote you if youcan answer in detail, not just in a few sentences. Thanks.
salesdt descr cost prc The date that the particular sales occurred A description of the item sold. The cost of the item (in cents). The price of the item (in cents).
date_trunc('month', salesdt), sum (prc) from sp.mast group by 1 order by 1 line 10, column 1, location 18 date_trunc 1 2013-01-01 00:00:00+00 2 2013-02-01 00:00:00+00 3 2013-03-01 00:00:00+00 4 2013-04-01 00:00:00+00 sum 9583179 12830204 17783417 20399001
Select date_trunc('month', salesdt), sum (prc) from sp.mast group by salesdt order by salesdt G line 19, column 1, location 36 date_trunc 1 2013-01-01 00:00:00+00 2 2013-01-01 00:00:00+00 3 2013-01-01 00:00:00+00 sum 215955 108301 91318