I have a table (maintable) of the format:
(id, intcol1, intcol2, intcol3, ...)
Sample data:
123, 582585, 25215718, 15519
234, 2583, 2371, 1841948
345, 42389, 234289, 234242
I want to run some aggregate calculations using outside data to group the data by. The data I have is of the form:
(id, groupcol)
Sample data:
123, "January",
234, "February"
345, "January"
In this case, suppose I want the SUM of intcol1 using the provided groupings to match IDs, the result would be:
"January", 624974 # 42389 + 582585
"February", 2583
My question is: How do I get the "group data" into the query? Using a WITH clause and JOINING it against the maintable? Or adding it to a temporary table and using that in a following query?
I can manipulate the data I have and format it however way is easiest from the program running the SQL query.
What is the best / fastest / simplest method?
Edited for clarity
624974in624974 + 582585come from?