Identifying Trends

  • 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.

  • 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.



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Here is an example

    SELECT Model, RentalDate

    FROM CARS

  • I would like to know if the number of cars rented each month is increasing or decreasing

  • 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.



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply