Hello there
I have a query that brings over the sum of cities... because we have multiple locations in those cities it breaks them down. For example:
Beaumont 1 - $50,000.00
Beaumont 2 - $25,000.00
I'd like to sum those in my query, so I can of course get $75,000.00... I'm not sure how to go about it... I'm thinking if it is possible, then it can be done through SQL. Just don't know how.
I attached a sample of what my query gives me... I'd like to sum those that are identical but exclude those that contain "SMALL" because thsoe are not really identical...
I also attached the SQL view of my query.
Last edited by jgomez; 10-06-2011 at 12:42 PM.
Do a Google for SQL GROUP BY
I see what you mean but how would i exclude? or can i even exclude??? I went here: http://www.w3schools.com/sql/default.asp
& I didn't see anything that allows me to exclude certain words...
i'm not sure... i never used SQL to build my queries.
Change
toWHERE ((([Total Balance of CC].CTR_NAME) Not Like "*ARMS*"))
WHERE [Total Balance of CC].CTR_NAME Not Like "*ARMS*" AND [Total Balance of CC].CTR_NAME Not Like "*SMALL*"
I think in general you would do something like this (not sure, but you might try it) -- I'm just using general table identifiers A & B -- this would just return
There's not a city field you can match? if not, maybe match the first 6 characters of the city name (or some number). use the join to get a partial match (like above) and the where clause to eliminate an exact match.SELECT SUM(A.Balance_Field), A.Name_Field From City as A JOIN City as B ON LEFT(A.Name_Field, 6) = LEFT(B.Name_Field, 6) WHERE A.name_field <> B.name_field (and any other conditions you used). Group By A.Name_Field
But i would think that in this table or another (that can join to it) you would have city information in it's own field.
Thank you both! I understand it now... somewhat. I couldn't successfully run a query when I would use SQL... i just did for the 1st time!!!
No city I can match but I can adjust the names... from Beaumont 1, Beaumont 2 to just Beaumont on both.... should do the trick.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks