Skip to content
Advertisement

Tag: group-by

Optimization of Group by Cube in SQL Server

I would like to make a GROUP BY CUBE of a table with 9 columns and more than 107 millions of rows. Here is an example of my code: This is running in SQL Server. For 10K rows it is taking 7 seconds, but when I increase the number of rows to the total 107 million it took more than

Order grouped table by id user sql

I want to order a grouped statement using as reference the number choosen by an specific user. TABLE expected result (at the end what user 1425 choosed) I want to put the last row with the number choosed by the user. i just cant figure that out Answer You can aggregate and use a conditional max for ordering, like so:

how to get sql result as objects

I have three tables: Table USER id name email Table CAMPUS id user_id (foreign key) name Table POST id title user_id (foreign key) A User belongs to a Campus, and a Post belong to a User. I want to write a query to fetch posts inner join with user inner join with campus. The result i get: [{ id username

Merge Two JSON array columns in Mysql 8

I am using Mysql (version > 8). I have a table where I am storing unique customer ids for the day in an JSON field as an array. I need to query for all unique customers in last 30 days. I am unable to find an equivalent mysql query for the same. I am using JSON_ARRAYAGG to first merge all

Combining some of the rows and sum them up in oracle sql

I`m working on some data manipulation and have table: I need to have and output to look like: Please suggest what can I use to combine and sum up those. I appreciate any input! Thank you Answer You can use aggregation. Values are strings, so you probably want to concatenate them rather than sum them (which makes no sense in

Advertisement