Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
fetch id who have register all adv

There are 3 types of adventures for which I used distinct function in query. There is only one 1 customer who have booked all types of adventures. The query i used to fetch the data is:


    select c.customerid,c.name
    from customer c 
        inner join booking b
            on c.customerid = b.customerid 
        inner join destination d
            on b.destinationid=d.destinationid
        inner join adventure a
            on d.adventureid=a.adventureid
    group by c.customerid
    having count(distinct b.bid)=(select count(*) from bid)
        or count(distinct a.adventuretype)=(
            select count(distinct a.adventuretype)
            from adventure
        )
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can get the customer ids using aggregation and having:

select b.customerid
from booking b join
     destination d
     on b.destinationid = d.destinationid join
     adventure a
     on d.adventureid = a.adventureid
group by b.customerid
having count(distinct a.advtype) = 3;

Or, if you don't want to hardcode the "3", you can use:

having count(distinct a.advtype) = (select count(distinct advtype from adventure)

I'll leave it up to you to add in the customer name (using join, exists, or in).

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda