Forum Moderators: open
I need to generate a report from a table in a standard MySQL query. I have numeric data that is grouped by the first 2 digits of a 4 to 5 digit number. I need to group the data and subtotal these groups in my query.
Example:
+---------+ +---------+
¦ Field 1 ¦ ¦ Field 2 ¦
+---------+ +---------+
14123 34
14234 45
14456 56
15123 67
15234 1
15345 23
In the above example I would need to grab the first three records (the records that start with (14) and then subtotal them to return the value of 135. Then the second group of three records (the 15's) with the subtotal of 91.
I have no idea how to make that work. Any assistance would be greatly appreciated!
Many thanks in advance.