Skip to content
Advertisement

Tag: postgresql

Randomly select orders per customer from database

DB-Fiddle Exptected Result: I have a huge database and need to extract some data from it for a case study. The problem is that I need to extract the full year of the data because I want to be able to conduct a monthly analysis in the case study. Therefore, I can not limit the extract with dates or LIMIT.

Join date to date range SQL

I have event on the calendar table as follows And I have a table daily as follows I would like to join these table to get the daily with the new column of event name base on specific country, for example: I will consider only US event. So the expected output should be the following table. May I know how

Get next row with clause A since last row with clause B

I have the following table: I am looking for a way to get all customers whose status is currently not ‘ok’ with an indication since when the status is not ‘ok’. The result should be: My attempt is the following, but it gives incorrect values for customers that are currently ‘ok’. The thing that I try to figure out is

Advertisement