I’m trying to group and order the number of sales made in each day from a single ‘sales’ table with a created_at column and an id column. Each of the records might be created through out the day at any time. I’ve managed to do this with the following query: However, the days with 0 sales are not shown up.
Tag: group-by
Oracle SQL Developer – group by and count within specific date
SQL noob, trying to get some help grouping by unique name, providing a count, filtered for only start dates during 2021. This is what I have so far, and why I’m getting lost. my_table: Trying to get count of the Name, filtered for only 2021 start dates. This is what I want my output to look like: My code: But
MYSQL Select different records from same table
I am working on small school database and I need some help with selecting students that are only booked on different days in week 1 and week 2. My table structure is like below: I would like to get all the children that meet the following criteria: ONLY booked in week two (This is ChildId 2 and I can get
Access Bare Columns w/ Aggregate Function w/o adding to Group By
I have 2 tables in postgres. users auth0_id email 123-A a@a 123-B b@b 123-C c@c auth0_logs id date user_id client_name abc-1 021-10-16T00:18:41.381Z 123-A example_client abc-2 … 123-A example_client abc-3 … 123-B example_client abc-4 … 123-A example_client abc-5 … 123-B example_client abc-6 … 123-C example_client I am trying to get the last login information (a single row in the auth0_logs table
SQL duplicates despite grouping on all key variables?
I am new to SQL and use it for work, so I am going to censor the real names of columns going forward in the query below. I am writing a query where the necessary data is spread across 3 tables. I have a network with users who send and receive packages from different nodes, and I want to see
Find duplicate values in a field results in multiple rows of the same values
Suppose this table I want to get all CODEs where SIZEPOS has the same value more than once… So for the product I would like to get ‘194342-01’, 10510, 5 as SIZEPOS 5 appears twice. I achieved it with the following query but for some reason some of the returned rows appear twice, or even three times… What am I
Counting unique values within a time window
I have data that looks like (over 100.000 rows): What I would like: Explanation CONTEXT I want to find out how many people (person) are working in the same location (Location) by looking at a time window (timestamp) of max 10 minutes and checking whether a person is really working simultaneously or just taking over their shift within that frame.
Average per hour adding an empty record if data is missing
I have this data: I need to store the average of each hour in a second table. I don’t know if I can also insert a NULL record if there is no data for an hour, maybe in a second treatment. I have tried with this first treatment but can’t do it. I get an error message and don’t know
Group items by 2 columns or similarity with another column
Let’s say we have a Sqlite table containing: How to group by h=CONCAT(city,age) but also add in the group the users that have a column foo identical to someone in the group? As seen in Group items by 2 columns, here is how to group by h: How to add this second condition on foo? Example: here Alice and Bob
How to Return Separate Sums of Columns if Initial Value in row is 0 in SQL
I am trying to write a SQL query that will return unique rows of sums of shipped part numbers per customer depending on if the value is negative or positive. For example: If we shipped 20 of part Z to customer A twice, and they returned 6 parts back to us, it would display: After running query, expected results: The