Skip to content

Tag: join

How can i make this Complex query for SQL database

I have a database that looks like this: Player (UserId, Mail, Password, Username, LastLogin) Leaderboard (UserId*, Level, Kills, Deaths) Match (MatchId, HostId*, ServerIp, StartTime, Team1Points, Team2Points) MatchStats (UserId*, MatchId*, Kills, Deaths) Weapons (IdWeapon, Name, Damage, FireRate, ReloadTime, …

JOIN on two tables

I have two tables: user: and credential: I want to perform a query to get the following result (one row for every user): Right now I am executing this query: This results in: I want a single row for a user. How can I achieve this? Answer You can use two joins:

Select most recent record (with expiration date)

Let’s say that we have 2 tables named Records and Opportunities: Records: RecordID CustomerID CreateDate 777 1 1/1/2021 888 2 1/1/2021 999 1 2/1/2021 Opportunities: OppID CustomerID OppCreateDate 10 1 12/31/2020 11 1 1/10/2021 12 2 2/1/2021 13 1 4/1/2021 14 1 8/5/2025 Desired Output: RecordID CustomerID…