Skip to content

Tag: sql

Union All with Join

I’m trying to perform a join after Union All. Separately the 2 queries work but I haven’t been able to piece together the join. The Unioned query needs to then be joing by assigned_user_id from the accounts table join Answer You need to make them subqueries, like this: I personally don’t lik…

SQL Query: finding cheapest car by company

Following YouTube tutorial “Learn PostgreSQL Tutorial – Full Course for Beginners”, I replicate teacher’s code but yields different result and cannot figure out why. Table is this simple: and so on, 1000 entries. Querying cheapest model from manufacturer, tutorial says: And it works pr…

MIN() vs LEN() Behaviors as Shortest String

I’m trying to solve a question in HackerRank called “Your Weather Observation Station 5”, the question asks to return the shortest and longest city names within the provided table. Demonstration to clarify my confusion: SELECT MIN(City) FROM STATION; Output: A name of city with 4 characters.…