Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: How to find smallest amount of something?

    Here's the info:
    Beers(name, manf)
    Bars(name, city, addr, license, phone)
    Drinkers(name, city, addr, phone)
    Likes (drinker, beer)
    Sells (bar, beer, price)
    Frequents (drinker, bar)

    Here's the question: Find the names of the bars in 'Boston' that sell 'Budweiser' for the cheapest price (compared with other bars in 'Boston').

    What I have so far:
    SELECT sells.bar
    FROM Bars, Sells
    WHERE bars.city LIKE 'Boston' and sells.beer LIKE 'Budweiser' and sells.bar=bars.name

    However, I forget how to find the cheapest price. I think I have to use ANY somehow, but i'm not sure how. A lil' help?

  2. #2
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    62
    HI

    I would try:

    SELECT sells.bar
    FROM Bars, Sells
    WHERE bars.city LIKE 'Boston' and sells.beer LIKE 'Budweiser' and sells.bar=bars.name
    AND sells.price = (select max(price) FROM Bars, Sells
    WHERE bars.city LIKE 'Boston' and sells.beer LIKE 'Budweiser' and sells.bar=bars.name
    )

  3. #3
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    detail: it's 'min(price)'
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •