asp.net - how to select the last 8 row and Sum other column in Database SQL Server -
I'm a newbie help me with this problem. I want to select the last 8 lines and other columns from the database. I have column week, date and value 1. I want to add the value 1 group to the week and only want to display the last 8 records. I can display the last 8 weeks, but can not add value1 My code is here to display the week:
select the week (weeks by the LAW ordinate / pre> This gives me the last 8 weeks, then I change it to change the amount in it (value 1):
as SELECT SUM (Value1) TValue1, week FROM (SELECT Top 7 week TBData By order by week, by DESC), but it gives me an error Invalid column name 'value1'.
What should I do to fix this ... Thanks in advance .. ..
there is no value1 column in your subquery. I hope That you want to do something like this: TVallue1, week FROM (SELECT Top 7 week, sum (Value1) as SELECT SUM (Value1) Diissi week by order of 1 somewhere on the week TBData Group)
Comments
Post a Comment