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 |
|
pyu.agrawal
Starting Member
29 Posts |
Posted - 2009-09-21 : 10:31:15
|
| i have two table pc_products and Tracking_productdetail whose structure is as follow.pc_productsproductid(pk)companyIdwhere as Tracking_productdetail as contain the following column.product_iduserIddatetime1typeoutput neededcompanyid, month & year(coming from Tracking_productdetail.datetime1), count of type. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-21 : 10:58:49
|
| [code]select p.companyid ,year( dateadd(month, datediff(month, 0, t.datetime1), 0)) as [year] ,month(dateadd(month, datediff(month, 0, t.datetime1), 0)) as [month] ,count(t.type) as typecountfrom pc_products pinner join tracking_productdetail t on t.productid = p.productidgroup by p.companyid ,dateadd(month, datediff(month, 0, t.datetime1), 0)[/code]Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|