Skip to content
Advertisement

Tag: count

SQL Sorted Count

I have the following table sorted by date: date id 9/1/20 1 9/1/20 2 9/3/20 1 9/4/20 3 9/4/20 2 9/6/20 1 I’d like to add a count column for each id so that the first count for each id is the earliest date and latest date would receive the highest count for each id: date id count 9/1/20 1

Count seen users per week

My input table looks like: id user_id at 1 1 2020-12-07 13:07:35 2 794 2020-12-07 13:12:17 3 794 2020-12-07 13:12:26 4 794 2020-12-07 13:12:27 5 263 2020-12-07 13:12:50 6 263 2020-12-07 13:12:50 7 263 2020-12-07 13:13:10 8 1029 2020-12-07 13:18:07 9 1029 2020-12-07 13:18:07 10 378 2020-12-07 13:19:10 11 378 2020-12-07 13:19:10 This table grows over time and will persist

How to choose in postgresql rows where amount of one value is bigger than another? [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question how to choose in postgresql rows where amount of one value is bigger

Count only non duplicate values

I need a query to count only values that aren’t duplicates, is there any way to do this without subqueries or temp tables? If I have a table like this: I can’t use SELECT COUNT(DISTINCT quantity) because it returns 4. (89 | 40 | 32 | 29) How can I return 2? (89 | 32) Answer Use a subquery:

Get total count of duplicates in column

I need a query to count the total number of duplicates in a table, is there any way to do this? If I have a table like this: I can’t use SELECT COUNT(quantity) because it returns 2. (40 | 29) How can I return 5? (40 | 40 | 29 | 29 | 29) Answer Using analytic functions:

Counting organizations which user has not contacted

I am new at PostgreSQL. I have the following tables created in my schema: User table: Organization table: And finally Organization_rating table: With this schema, an organization has a business type in which gives support to the user that also have that business type. After giving this support, the user can rate this organization with organization_rating. Following this logic, I

Advertisement