How to hide rows where aggregate functions are used

let’s imagine here is my report: select 1 from dual union all select 2 from dual union all select 3 from dual union all select 4 from dual Output: 1 2 3 4 If e.g. i want to hide part of the report …

Limited By Value Postgresql query

I have a couple of rows where values in one column are repeating and I need to get a couple of rows where every value is limited by const. For example, i have this rows (1, ‘a’) (2, ‘b’) (3, ‘a’) (4,’…

Order by with formatted dates, doing it right?

I wanted a mere sanity check because I have a slight feeling I am doing it all wrong. I stripped down the use case to a very simple sample. When formatting a date I need to cast the data in the order …

How do you populate boolean columns based on a table of properties?

I have a table called Product that contains a product identification number and an id associated with the product identification number. pin id 11 10 12 11 13 12 I also have a property table with the …

Postgres SUM over given time

I am trying to SUM google analytics data over a given time using Postgres. I am not quite sure how to get around a grouping issue. The query you see below returns one column per day. I want to SUM all …

SQL: Expression Not in GROUP BY Key

I have a transaction table t1 in Hive that looks like this: store_id cust_id zip_code transaction_count spend 1000 100 123 3 50 2000 200 …

Find Nth value and average value corresponding to each group in SQL

I have a table with name and grades for some users CREATE TABLE grades (name varchar(100), grade integer); insert into grades values (‘Bob’, 12), (‘Bob’, 13), (‘Bob’, 23), (‘Bob’, 17), (‘James’, 15), (…

Date distinct count over week

Im trying to get a distinct count of user ids logs per day with every week as a partition for the distinct identification. e.g. if one user logs on Friday/Saturday of week 1, and on Monday/Friday of …

Select rows in left join which depend on sum of a field in the other table?

Im trying to write a SQL left outer join query where the left rows are selected based on the sum of a field in rows in the other (right) table. The other table has an id field that links back to the …

Postgres: how to check for records in time buckets for multiple values

I have a POSTGRES table with roughly the following shape: sensor_id | recorded_at ———-+——————– A | 2020-01-01 00:00:00 A | 2020-01-01 00:03:00 B | …