April 21, 2010 at 12:58 pm
I'm doing a query and I should know how I do this, but I just can't think of it right now. So, I'm query a table and the two main fields that I'm looking at is a field called LRSN and IMP_VAL. The LRSN identifies the item that I'm looking for and the IMP_VAL shows how much of an improvement value has been added to that value. So, what I want to do, if I have a record that has the same LRSN, add the IMP_VAL from all the records and give me a grade total. So, lets say I have a record with a LRSN of 12345 and then a IMP_VAL of 10000. Then I have another record with LRSN of 12345 and an IMP_VAL of 20000. In my results of my query I just want to show LRSN 12345 with a total IMP_VAL of 30000. I know that there is a way of doing it, I'm just not thinking right now.
Any help would be great!
Thanks,
JOrdon
April 21, 2010 at 1:00 pm
jordon.shaw (4/21/2010)
I'm doing a query and I should know how I do this, but I just can't think of it right now. So, I'm query a table and the two main fields that I'm looking at is a field called LRSN and IMP_VAL. The LRSN identifies the item that I'm looking for and the IMP_VAL shows how much of an improvement value has been added to that value. So, what I want to do, if I have a record that has the same LRSN, add the IMP_VAL from all the records and give me a grade total. So, lets say I have a record with a LRSN of 12345 and then a IMP_VAL of 10000. Then I have another record with LRSN of 12345 and an IMP_VAL of 20000. In my results of my query I just want to show LRSN 12345 with a total IMP_VAL of 30000. I know that there is a way of doing it, I'm just not thinking right now.Any help would be great!
Thanks,
JOrdon
select
LRSN,
sum(IMP_VAL) as SumIMPVAL
from
dbo.MyTable
group by
LRSN;
April 21, 2010 at 1:02 pm
Perfect! Thank you!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply