June 18, 2012 at 3:49 am
Where FieldId and FieldValues are repeating, i need to query sum of field values based on the dates.
EX - select sum(Fieldvalue) from EntityItemDetails where fieldid=21 and ((FieldValue<='12/20/2011' ANd FieldId=19) and ((FieldValue>='12/20/2011' ANd FieldId=19)))
June 18, 2012 at 5:20 am
Hi,
I'm not sure exactly what you are asking but I think you are refering to a 'GROUP BY', check out BOL and see if that's what you are after.
If not then can you clarify in a bit more detail what you are trying to acheive please?
June 18, 2012 at 6:03 am
June 18, 2012 at 6:49 am
You will need to start from here:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 18, 2012 at 6:52 am
Hi,
Yes, I think you should be able to do this using a GROUP BY, if you are not familiar with that then there are loads of good examples on the internet, and BOL (Books OnLine) will document it as well.
It's pretty much like saying, I have 3 columns (Country, Town and number of people). You would say the following;
SELECT Country,
Town,
SUM(NumberOfPeople)
FROM TableA
GROUP BY Country,
Town
You are just saying, sum the people, by Country and Town.
You just need to change this to work with your table and columns.
If after you've read about it you still need some help then let me know.
Nic
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply