I have a list of multiple clip ids e.g. 1,2,3,3,3,3,4,4,4,5,5,5 and in the second column, i have a duration in frames - each clip only has one durat开发者_开发知识库ion - what query can i write to add up all the durations for each unique clip? It's been stumping me for a while
Currently SELECT SUM(framecount) FROM myTbl
returns a really high clip duration (as many clips are being counted twice). e.g. I have 5 clips in my system, with a duration of 10,20,30,40,50 but each clip may appear in the list i'm talking about above 20 times each.
Thanks!
I believe you want to use the GROUP BY function:
SELECT clip_id, sum(framecount) FROM myTbl GROUP BY clip_id
精彩评论