Skip to content

Tag: sql

Combining MAX and SUM in an Oracle ROLLUP

Here’s my SQL: The output looks like this: I was expecting it to look like this: In other words, I was expecting the rollup to sum up the maximum weights of each food instead of taking the maximum of all the maximums in the food-type category. I do have a solution of sorts, but it means having to add an

Add Sequential Letter column to table

In C I can switch between int and char to build a list of sequential integers and then convert them to ASCII characters that will be sequential according to the alphabet. Is there a way to do this in …

Query to modify where clause to specify relation

I have 2 tables: users & user_roles users: id name 1 John 2 Doe user_roles: user_id role 1 admin 1 finance 1 accounting 2 admin 2 finance 2 admin I want to get the users that have admin & finance roles in the output(with distinct). So the result will be only user with ID of 2 (Doe) What is the