Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query (maybe simple)
    primarykey
    data
    text
    <p>So i'm having this problem.</p> <p>I have two tables (Oracle), one is called Destination and the other one Reserve. Reserve has a foreign key to the id of Destination (Because on reserve has one destination). And reserve tuples means all the reserves that all the users have done. I need a way to check the top 3 most visited Destinations (based on the foreign key in the table Reserve).</p> <p>How can I do that with SQL in Oracle. I know that I need to search within the Reserve tables for the 3 most repeated Destinations ID's, and later join that with the Destination table to get the details of the top 3 destinations.</p> <p>Any help is valid. Thank you very much.</p> <p>SCHEMA:</p> <pre><code>-------------------------------------------------------- -- File created - martes-septiembre-15-2009 -------------------------------------------------------- -------------------------------------------------------- -- DDL for Table DESTINO -------------------------------------------------------- CREATE TABLE "S2501A29"."DESTINO" ( "PK_ID_DESTINO" NUMBER(10,0), "FK_COD_UBICACION_GEOGRAFICA" NUMBER(10,0), "NOMBRE" VARCHAR2(10), "FOTO" VARCHAR2(30), "DESCRIPCION" VARCHAR2(50) ) ; -------------------------------------------------------- -- DDL for Table LUGAR_ESTADIA -------------------------------------------------------- CREATE TABLE "S2501A29"."LUGAR_ESTADIA" ( "PK_ID_ESTADIA" NUMBER(10,0), "NOMBRE" VARCHAR2(10), "TIPO" VARCHAR2(10), "DESCRIPCION" VARCHAR2(50), "COSTO_SERVICIOS" NUMBER, "DESCRIPCION_ALOJAMIENTO" VARCHAR2(100), "DESCRIPCION_ALIMENTACION" VARCHAR2(100) ) ; -------------------------------------------------------- -- DDL for Table OPCION_TRANSPORTE -------------------------------------------------------- CREATE TABLE "S2501A29"."OPCION_TRANSPORTE" ( "PK_ID_VIAJE" NUMBER(10,0), "MEDIO_TRANSPORTE" VARCHAR2(10), "RESPONSABLE" VARCHAR2(10), "CIUDAD_ORIGEN" VARCHAR2(10), "CIUDAD_DESTINO" VARCHAR2(10), "COSTO" NUMBER ) ; -------------------------------------------------------- -- DDL for Table RESERVA -------------------------------------------------------- CREATE TABLE "S2501A29"."RESERVA" ( "PK_ID_RESERVA" NUMBER(10,0), "FK_COD_DESTINO" NUMBER(10,0), "FK_COD_ESTADIA" NUMBER(10,0), "FK_COD_VIAJE" NUMBER(10,0), "TARJETA_CREDITO" VARCHAR2(12), "FECHA_SALIDA" DATE, "FECHA_REGRESO" DATE, "NOMBRE_USUARIO" VARCHAR2(50) ) ; -------------------------------------------------------- -- DDL for Table UBICACION_GEOGRAFICA -------------------------------------------------------- CREATE TABLE "S2501A29"."UBICACION_GEOGRAFICA" ( "PK_ID_UBICACION" NUMBER(10,0), "CIUDAD" VARCHAR2(10), "PAIS" VARCHAR2(10), "CONTINENTE" VARCHAR2(10) ) ; </code></pre> <p>Just a note:</p> <p>RESERVE is Reserva DESTINATION is Destino </p> <p>Because the DB is in spanish. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload