Skip to content

Tag: sum

Multiple SUM in one query with multiple where

I’m trying to write a SQL query that produces a table with summarized values for each year and month. I have a table that looks something like this: And another table that looks like this: I want to have a query that returns the sum for each month like this: Explanation of the output: Year and Month are obvious RegTime

Get comments per video and total sum of comments per video channel

In addition to Get total sum of video comments for each video I noticed that I can’t use v.commentCount because I cleaned some data and now the column is inaccurate. So I need to count the videoId comments and the total videoID comments with the comment table. I have a table video and a table comments. video.channelId maps to comments.videoID_channelID

Subtract values from the same Column in sql? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 2 years ago. Improve this question

MySQL sum() from more than 1 table

Ok, so every sum() returns the desired value, I already checked it but I’m having problems when trying to sum everything together and then get the total value. Basically I have to do this: initial Fee(which is a set value defined on the”customer” table) + sum of activity1 cost + sum of activity2 cost == value But I don’t know