I have a dataset like this: Here in this dataset, there is No NULL value for all these 3 columns, also user_name and recording_msid pair can repeat but each repeated pair will have a distinct …
Tag: group-by
Getting the result of sum / count with two different conditions
I’ve been trying to extract to average times (based on some criteria). I need to get two results. These two results are based on how many minutes between two times, divided by the quantity of …
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
SQL bring number of count, another column basis problem [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have this table: BANK – BRANCH_NAME – ADDRESS – DISTRICT – CITY – PHONE – FAX – OPENNING DATE How do I bring branches
Fill in missing dates and grouping problem
I have a table with Case records with CaseId, UserId, Opened date, Closed date etc value. For reporting I need to have a result table with all users by continuous months with number of case still …
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
MySQL query to sum one column and count another column, from two tables, based on a common value?
I’m having issues getting my head around a query that I am trying to build. I’m hoping for a bit of help here… I have two tables. Each table has two columns. They are described as follows: Table: “Token” Table: “Score” I want a query that will list each name once, and with each name the sum of Points for
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