Mysql Date and Number formats

I have a staging table where I have the data for every time-stamp. For aggregated tables, I need to ‘group by’ the timestamp in year-month format. For this DATE_FORMAT(sample_date, '%Y-%m') function is used. This will give the output 2016-01.

While grouping the data by year-month format, I should have a sum of the data corrected to two decimal points. Hence
round()

function is used.

round(sum(share_price),2)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s