February 12, 2016 at 4:34 am
Hi,
I have this statment group by
SELECT wh_id as Wh, count(*) as Plan FROM Backtest where wh_id in (1,9) group by wh_id
In a table i have the field create_dtim in this format 07-11-2015 10:58:38.
Ho i can have the result by month because i need a count for every records by month?
Thks a lot for help,
Regards,
JC
February 12, 2016 at 4:38 am
I haven't tested this, but something like this should do the trick.
SELECT wh_id as Wh, dateadd(m,datediff(m,0,create_dtim),0),count(*) as Plan FROM Backtest where wh_id in (1,9) group by wh_id, datediff(m,0,create_dtim)
February 12, 2016 at 5:15 am
Hummm,
Donยดt work ask me for parameter m and wh.
๐
JC
February 12, 2016 at 5:21 am
Assuming create_dtim is a valid date field
SELECT wh_id as Wh,
MONTH(create_dtim) as MonthCreated,
YEAR(create_dtim) as YearCreated,
count(*) as Plan
FROM Backtest
where wh_id in (1,9)
group by wh_id, MONTH(create_dtim), YEAR(create_dtim)
Is that what you're after?
February 12, 2016 at 5:58 am
Thks a lot.
Work ๐
Best regards,
JC
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply