Rentals: Объявления в Amsterdam

Easy

Войдите, чтобы сохранялся прогресс.

Выведите объявления, расположенные в городе Amsterdam. Ожидаемые колонки: id, title, city, price_per_night

Структура таблиц

PRAGMA foreign_keys = ON;

  CREATE TABLE hosts (
    id INTEGER PRIMARY KEY,
    host_name TEXT NOT NULL,
    country TEXT NOT NULL
  );

  CREATE TABLE listings (
    id INTEGER PRIMARY KEY,
    host_id INTEGER NOT NULL,
    title TEXT NOT NULL,
    city TEXT NOT NULL,
    nightly_price INTEGER NOT NULL,
    max_guests INTEGER NOT NULL,
    FOREIGN KEY(host_id) REFERENCES hosts(id)
  );

  CREATE TABLE bookings (
    id INTEGER PRIMARY KEY,
    listing_id INTEGER NOT NULL,
    guest_name TEXT NOT NULL,
    checkin TEXT NOT NULL,
    nights INTEGER NOT NULL,
    guests INTEGER NOT NULL,
    status TEXT NOT NULL, -- confirmed | cancelled
    FOREIGN KEY(listing_id) REFERENCES listings(id)
  );

  CREATE TABLE reviews (
    id INTEGER PRIMARY KEY,
    booking_id INTEGER NOT NULL,
    rating INTEGER NOT NULL, -- 1..5
    comment TEXT,
    FOREIGN KEY(booking_id) REFERENCES bookings(id)
  );

Пример данных

bookings

id listing_id guest_name checkin nights guests status
1 2 Guest 1 2026-01-02 2 2 confirmed
2 3 Guest 2 2026-01-03 3 3 confirmed
3 4 Guest 3 2026-01-04 4 4 confirmed
4 5 Guest 4 2026-01-05 5 5 confirmed
5 6 Guest 5 2026-01-06 6 1 confirmed

Показано строк: 5 (LIMIT 5)

hosts

id host_name country
1 Host 1 DE
2 Host 2 FR
3 Host 3 ES
4 Host 4 NL
5 Host 5 DE

Показано строк: 5 (LIMIT 5)

listings

id host_id title city nightly_price max_guests
1 2 Listing 1 Utrecht 70 2
2 3 Listing 2 Rotterdam 80 3
3 4 Listing 3 Eindhoven 90 4
4 5 Listing 4 Amsterdam 100 5
5 6 Listing 5 Utrecht 110 1

Показано строк: 5 (LIMIT 5)

reviews

id booking_id rating comment
1 2 2 good
2 3 3 great
3 4 4 ok
4 5 5 good
5 6 1 great

Показано строк: 5 (LIMIT 5)

Ваш SQL

Результат

Результат пуст (0 строк).