Skip to content
Advertisement

Tag: sum

SQL Combining MAX and SUM

So I have one SQL table that contains the below columns: There are ~2800 unique License numbers and will have numerous FundsIn each day. I am trying to find the last date there was activity (ActivityDate) and the sum of all of the FundsIn on that MAX ActivityDate. Below is a query I’ve been trying to modify to get it

How query two different Sum from the same table for the same column but with different condition?

I would like to fetch the sum of field TOTAL for active users and sum of field TOTAL for inactive users. Expecting is the query that results activeTotal = 15 and InactiveTotal = 50 SELECT SUM(actUser.total) as activeTotal, SUM(inActUser.total) as inactiveTotal FROM user actUser JOIN user inActUser ON inActUser.id = inActUser.id WHERE (actUser.active = 1 AND actUser.userId = 1) OR

right way to get sum of all the counts done in sql

This is my query, I want to get how many numbers of phones call received today as one column, so how do I do a sum using count function? If I do a sum, that would just return the total sum? how do I return the total numbers of all calls received today, I would do count uniquecallerID and then

SQL group and summing at new row

I have an issue where I am trying to create a new “row” (not part of the database) where it only gives me the SUM of the “count” column. I am wondering if that is possible? I tried adding the SUM(count(cost) as “total product cost” OVER() AS Total_Count; but that just creates a new column with the summed amount of

SQL query using Sum() and count() functions

I’m trying to query in PostgresQL using the SUM function to get the total of 3 different row types (Root, Dynamic, Test). I used the Sum() function for the first attempt and the Count() function for the second attempt; both didn’t work sadly. I expect a syntax error (since I’m a beginner at using SQL), but I’m not sure what

SQL Group by Transpose

I have the following Table charges Using the following query gets my the counts by Charge and Date Is there a way to transpose this to get the following? Thank you. Answer Use conditional aggregation:

Oracle SQL – Sum next X number of Rows

I have a table in Oracle database whith projected sales per week and would like to sum the next 3 weeks for each week. Here is an example of the table for one product and what I would like to achieve in the last column. I tried the Sum(Proj Sales) over (partition by Product order by Date), but I am

Advertisement