Skip to content
Advertisement

Tag: sum

Update and renew data based on data in other tables

There are 3 tables student, course, and takes as following tot_cred column data in the student table now is assigned with random values (not correct), I want to perform the query that updates and renews those data based on the course’s grade each student has taken. For those students who received F grade will be excluded and those who didn’t

Postgresql sum not working as expected when it is clear

I am solving the following Hard Leetcode SQL Question. Link to Question: https://leetcode.com/problems/trips-and-users/ (You can directly look at the solution and understand the problem) Question: Trips table: Users table: Output: Here’s my code: And the output is: How is the cancellation_rate is 0.00 when it is clear by looking at previous columns(s/c) that it should be 0.33,0.50, 0.00. Answer The

SQL Insert into duplicates

My code is as follows: I should explain the SUM(), there are differing dates on schedule such as I want to get all the “count” of “serviceId” beyond today hence the ‘date >= GETDATE()’ Basically I want the table to look like so: I am able to get the values but I get them like so: Whereas I want to

SQL SUM values by DISTINCT column after JOIN

I’ve been searching the forums for a solution for hours now but I couldn’t quite find the one that is fitting for my problem. I have two tables: members **************** id name city 1 John Boston 2 Maria Boston 3 Steve London 4 Oscar London 5 Ben Singapore donations ******************** member_id amount 1 100 1 150 2 300 3 50

Advertisement