-1

i have a table contains columns cost,date,customer-id,products bought i can create daily reports but now i want to create monthly reports as sum of cost. i have a grid view to show it please explain me clearly am a beginner to this .net what should be done in grid view and what should be the sql query i am using grid view manually generated columns daily basis are customer-id,date,cost,products bought

for monthly reports

i am using grid-view columns cutomerid,month,year,cost

what should be the sql query

wruckie
  • 1,717
  • 1
  • 23
  • 34
Tajkumar
  • 317
  • 2
  • 5
  • 16
  • 1
    Please don't just ask us to solve the problem for you. Show us how _you_ tried to solve the problem yourself, then show us _exactly_ what the result was, and tell us why you feel it didn't work. See "[What Have You Tried?](http://whathaveyoutried.com/)" for an excellent article that you _really need to read_. – John Saunders Jan 26 '14 at 03:51

1 Answers1

0

Your issue is not .net, but SQL. Write the query first, displaying it in your app will phase 2. Do you have reporting services?

Select sum(cost), [Month], [Year], customer-id from 
( 
   Select cost, Month(date) as [Month], Year(date) as [Year] , customer-id
   from customerbooking where date >= '2-1-2014' and date <= '2-28-2014'
) as a
Group by [Month], [Year], customer-id
wruckie
  • 1,717
  • 1
  • 23
  • 34