İ have a video table named videos and here these are the columns :
vid v_uid v_view v_title v_info
1 45 56487 foo foo
2 45 455
3 45 98989
...
My condition will be ” where v_uid = 45 ” and i want to get rows belongs to this id “45” and sum this users video views as total views.
thanks.
I read the question as you want to get all rows and a sum of those rows in one query.
You could do this all in one hit using WITH ROLLUP, e.g.
Bit hacky, as we don’t really need the group by (which is why I’m grouping on the row id vid). What you’ll end up with all the individual rows, and a final row with the total sum in it (it will have a NULL vid too, which might help identify it)
If you just want a sum of the views, then you can execute something much simpler