I want to add the val_col based header_id and bill_name
Input:
bill_name header_id va_col id
23823 62259 40 7
23823 62259 7 8
23824 62254 20 7
23824 62254 40 9
23825 62257 10 7
Output:
bill_name header_id total
23823 62259 47
23824 62254 60
23825 62257 10
Seems like a very basic aggregation query:
select bill_name,
header_id,
sum(va_col) as total
from the_table
group by bill_name, header_id;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.