database - Find all users having rented every car in SQL -


find users having rented every car in sql

the database has following structure (the primary keys in bold):

  • rent (people, cars, daterent, expectedreturndate, effectivereturndate)
  • lateness (people, cars, daterent, latenessfee)

my attempt:

select rent  forall cars exists daterent 

can me expressing correctly such query?

from you've provided, following works.

first, want determine how many different/unique cars there are:

select count(distinct car) rent) 

next, want select people have rented every different/unique car - 1 way checking count of distinct cars each person same count of distinct cars:

select people rent  group people having count(distinct car) = (select count(distinct car) rent) 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -