stamin4
  • whoami
  • HTB Academy
    • Introduction to Academy
    • Learning Process
    • Vulnerability Assessment
    • Web Requests
    • Introduction to Networking
    • Linux Fundamentals
    • Brief Intro to Hardware Attacks
    • Setting Up
    • Using the Metasploit Framework
    • Security Incident Reporting
    • Introduction to Web Applications
    • JavaScript Deobfuscation
    • Attacking Web Applications with Ffuf
    • Windows Fundamentals
    • File Inclusion
  • HTB Machines
    • Windows
      • 馃煝Easy
      • 馃煚Medium
      • 馃敶Difficult
      • 馃煟Insane
    • Linux
      • 馃煝Easy
        • Cap
      • 馃煚Medium
      • 馃敶Difficult
      • 馃煟Insane
  • OverTheWire
    • Bandit
      • Nivel 0
      • Nivel 1
      • Nivel 2
      • Nivel 3
      • Nivel 4
      • Nivel 5
      • Nivel 6
      • Nivel 7
      • Nivel 8
      • Nivel 9
      • Nivel 10
  • Base de datos
    • SQL
      • SELECT queries 101
      • Queries with constraints (Pt. 1)
      • Queries with constraints (Pt. 2)
      • Filtering and sorting Query results
      • Simple SELECT Queries
      • Multi-table queries with JOINs
      • OUTER JOINs
      • A short note on NULLs
      • Queries with expressions
      • Queries with aggregates (Pt. 1)
      • Queries with aggregates (Pt. 2)
      • Order of execution of a Query
      • Inserting rows
      • Updating rows
      • Deleting rows
      • Creating tables
      • Altering tables
      • Dropping tables
  • PortSwigger
    • Path Traversal
  • Dockerlabs
    • Trust
    • Firsthacking
    • Upload
Powered by GitBook
On this page
  1. Base de datos
  2. SQL

Simple SELECT Queries

SQL Review

  1. Lista todas las ciudades canadienses y su poblaciones.

SELECT city,country,population 
FROM north_american_cities 
WHERE country = 'Canada';
  1. Ordena todas las ciudades de Estados Unidos por su latitud de norte a sur.

SELECT * 
FROM north_american_cities 
WHERE country = 'United States' 
ORDER BY latitude DESC;
  1. Lista todas las ciudades al oeste de Chicago, ordenadas de oeste a este.

SELECT * 
FROM north_american_cities 
ORDER BY longitude ASC 
LIMIT 6;
  1. Lista las dos ciudades m谩s grandes de M茅xico en poblaci贸n.

SELECT * 
FROM north_american_cities 
WHERE country = 'Mexico' 
ORDER BY population DESC 
LIMIT 2;
  1. Lista la tercer y cuarta ciudad con mayor poblaci贸n de Estados Unidos y dicha poblaci贸n.

SELECT city, population 
FROM north_american_cities 
WHERE country = 'United States' 
ORDER BY population DESC 
LIMIT 2 OFFSET 2;
PreviousFiltering and sorting Query resultsNextMulti-table queries with JOINs

Last updated 1 year ago