Lynn Emery

Lynn Emery

  • NA
  • 47
  • 56.3k

SQL 12 Month graph

Feb 18 2013 4:17 AM
Hi,
I have a problem regarding a Dundas Chart Graph and an SQL statement.

I want to create a graph which will show customer sales for the last 12 months.
I have created an aspx page with 3 dropdown lists and a Dundas chart which are connected by and SQL DataSource. The first dropdown list is to selects the customer, the 2nd selects month, and the thrid selects year. These dropdown boxes have been set up to access data from a database view.

At the moment if I select customer 'A', Month 'June' and Year '2012' from the dropdown lists the dundas chart will display sales for customer A up until June 2012 it displays 6 months. However I want it to plot 12 months of sales. Therefore if I select june 2012 it should show data from june 2011 to june 2012.
Essentially I want to display 12 months of data up until the month and year selected from the dropdownlists.

The  code I am currently using for SQL Data Source is :

SELECT * FROM [Sales] WHERE (([Month]< = @Month) AND ([Customer] = @Customer) AND ([Year] = @Year)) ORDER BY [Month]

Sorry if there is a simple colution for this problem, but I am very new to SQL and C#.

Thank you for your help.