Most asked SQL Question with Answer | Robinhood - Cities With Completed Trade

Опубликовано: 15 Декабрь 2024
на канале: ETL-SQL
136
4

Free SQL Pattern Training: https://etlsql.kartra.com/page/sps-fr...

Do you understand SQL but still cannot write SQL queries correctly ?
Are you afraid to switch jobs because of the SQL interview rounds or have you failed SQL Interview earlier ?
If you are someone who understands SQL and need more confidence to solve SQL queries correctly, I would like to share my recent online course especially created for you.
Check for more details: https://etlsql.kartra.com/page/sql-pa...

In this video I have solved SQL Question - Titled "Cities With Completed Trade" on Data Lemur platform.
Data Lemur referral link for easy reference: https://bit.ly/3SuF3wf

Hope you like the way I am explaining my thought process.
Let me know if this is helping you to solve SQL queries more confidently and you wish me to share more such videos.

Question:
You are given the tables below containing information on Robinhood trades and users. Write a query to list the top three cities that have the most completed trade orders in descending order.

Output the city and number of orders.

Solution:
#############################

select u.city, count(*) as total_orders
FROM
trades t
inner join
users u
ON
t.user_id = u.user_id
where t.status='Completed'
group by u.city
order by total_orders desc
limit 3;

#############################