Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
MelissaTsalicoglou
Starting Member
16 Posts |
Posted - 2014-06-05 : 07:13:08
|
Select Year(orderdate) * 100 + MONTH(orderdate) as yearmonthno, SUM(d.qty * d.unitprice) as salesamountpermonthFrom Sales.Orders as oInner join Sales.Orderdetails as d on d.orderid = o .orderidGroup BY Year(orderdate), Month(orderdate) Order by yearmonthno; |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-06-05 : 07:17:08
|
let's say orderdate is today ie. 2014_06_05year(orderdate) gives 2014month(orderdate) gives 6addition would give 2020 but needed is 201406this is why 2014 * 100 is usedso we have 201400 + 6 give 201406 Too old to Rock'n'Roll too young to die. |
|
|
|
|
|