I'm trying to understand the logic behind the group by and the possible alternatives to it.
That's why, I've been trying to solve a puzzle where I try to make the same as with a group by clause but ...
I have the following schema, that represent collection of messages, where each message can have multiple items (at least 1). Every item belongs to a message. Items can change over time.
CREATE TABLE ...
I wrote a query to sum salaries grouped by Country and Gender. I don't want the rows to show NULL or empty values for the totals, instead I want it to show Total and Grand Total to better describe the ...
What would be the best way to aggregate across hierarchies?
I am using Postgres and have the following 3 tables (folder, folder_hierarchies, and work) -
So I have to group a table according to the date and then the timeday when a product arrived, the timedays would be:
morning = [5, 6, 7 , 8, 9]
mid_morning = [10, 11]
midday = [12, 13, 14]
evening = [...
I'm passing a JSON string to a stored procedure in order to insert warehouse inventory.
Sometimes, there will be multiple line items with the same product, going to the same shelf, on the same pallet (...
I have a table of team players in which the PlayerID is missing in some rows.
CREATE TABLE TeamPlayers
ID int(11) unsigned NOT NULL AUTO_INCREMENT,
TeamID int(11) unsigned NOT NULL,
PlayerID int(11) ...
Currently working with Spark data frames using HQL syntax (which slightly differs from SQL). I'm trying to aggregate a table by id and want to select the feature row by the most recent date (they may ...
I need a simple query, but couldn't find the way to do it:
I have a table of services purchased by customers, where different customers may purchase the same service (trivially), and each customer may ...
I came across this question yesterday. I am looking for an explanation for just one point.
Which of the following statements are TRUE about an SQL query?
P : An SQL query can contain a HAVING clause ...
Is there a way to separate a query that has a group by attribute in Postgres in a fashion similar to sqlplus?
Assuming I have branches of my company in every country, is there a way to have a separate ...
First of all I am sorry if this is a basic question, I am new to queries in MongoDB. Well, what I need is to find the latest registers for a worker in my WorkerLocationContext document and the latest ...
I am trying to replace a lot of queries like this with a single query.
SELECT * FROM y WHERE x = a ORDER BY timestamp LIMIT 50
SELECT * FROM y WHERE x = b ORDER by timestamp LIMIT 50
SELECT * FROM y ...
I'm a novice, trying to find the best way to sum up my data. Oracle 19c.
I have a WORKORDER table that has work orders (ISTASK=0) and tasks (ISTASK=1).
Tasks are children of work orders.
Work orders ...
I have a patient with 2 rows that have same admit and discharge dates and their admit flag is 1 and los is 14, 15 and other patient with 3 rows with different admit and discharge dates that have admit ...
I have two mapping tables as
CREATE TABLE ProjectDevelopers
DeveloperID int(11) unsigned NOT NULL,
ProjectID int(11) unsigned NOT NULL,
I am running a larger DB with tables > 200M datasets on a dedicated Ubuntu 20.04 machine.
Since a few days queries that use group by are extremly slow. I suspect that this is new since the last apt-...
I want to get a list of dates where there are consecutive dates and it's corresponding count.
For example, if the I have the following data set
I'm trying to group by the result of a jsonb operation on an aliased field, but getting an error I would not expect.
The following work as expected:
select jsonb_build_object('x', 1) as a group by a;