Skip to content

Get max dates for each customer

Let’s say I have a customer table like so: I want to get 1 row per customer id that has the max(start_date) and if it’s the same date will use the max(created_at). Result should look like this: I’m having a hard time with window functions as I thought a partition by id would work but I have …

Oracle SQL: Get the previous values

I have two columns table: Id, and value. ID Value 1 2 AA 3 4 BB 5 6 7 8 CC 9 I need a query in Oracle to return the result as ID Value 1 2 AA 3 AA 4 BB 5 BB 6 BB 7 BB 8 CC 9 CC Is there anyway to do this? Thanks in

How does SQL subqueries use outside variables

select sName, GPA, sID from Student S1 where not exists (select sName from Student S2 where S2.GPA > S1.GPA) Say the above query. How does the following line work? (select sName from Student S2 …

Joining three junction tables

my heads hurt from trying to figure this out! I have three tables -Players -Teams -Games Three junction tables with two columns. -player_teams -teams_games -player_games I need to list all Players who …