Skip to content

Tag: postgresql

How to aggregate and group by in each column?

I have this table: I’d like to summarize major and minor columns to get this result: Is there any way to achieve this? I tried: But it didn’t count each number. Answer You may achieve this using window functions. major minor major_count minor_count A a 3 2 A b 3 1 B c 2 1 B d 2 1 View

marked user with label by time for each month

Data source User ID Visit Date 1 2020-01-01 12:29:15 1 2020-01-02 12:30:11 1 2020-04-01 12:31:01 2 2020-05-01 12:31:14 Problem I need advice im trying to do sub query for this result to mark user as retention if they havent visit back for 3 month. i using this query for the data to get user’s latest vis…

How to count number if special type of value by day in SQL?

I have a table in my database which looks like this: I want to get table with number of upload value_types per day (my time column is not per day as you see). So for this example it must look like: How should this SQL query look like? I dint understand turning time into days part especially. Answer You seem