October 31, 2013 at 9:44 am
Hi,
I am trying figure how to find the trend for some data.
For example, we have cars that are rented each day. I am trying to figure out the trend per month over a couple of years.
Any help is appreciated.
October 31, 2013 at 9:48 am
Please look at the article in my signature about posting questions on the forum. We will need some table structures and some sample data with an expected output. Once you get us that someone should be able to help you with your question.
October 31, 2013 at 9:59 am
Here is an example
SELECT Model, RentalDate
FROM CARS
October 31, 2013 at 10:00 am
I would like to know if the number of cars rented each month is increasing or decreasing
October 31, 2013 at 10:22 am
Well with out table structure and data you could use the following:
create table CARS (Model varchar(100), RentalDate datetime);
go
insert CARS
values ('Camry','20120101')
,('Accord', '20120201')
,('Accord', '20120202')
,('Camry','20130101');
go
select DATEPART(year,RentalDate) as RentalYear, DATEPART(month,RentalDate) as RentalMonth, Model, count(*)
from CARS
group by DATEPART(year,RentalDate), DATEPART(month,RentalDate) , Model
If this isn't what you are looking for then please provide the correct create table statement and sample data.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply