SQLite Forum

Help to find a specific result

Help to find a specific result

(1) By anonymous on 2020-04-23 11:52:53 [link] [source]

So I have a database with 3 tables:
-producer: nprod, last name, first name, region
-harvest: nprod, nwine, quantity, year
-wine: nwine, wine, proof

Some examples of these values:
-nprod: unique number assigned to a producer
-nwine: unique number assigned to a wine
These last two are mainly used for natural joins but also to count producers & wines with count().
-last name: Michon
-first name: Philippe
-region: Alsace
-quantity: quantity harvested of a specific wine
-year: 2002
-wine: Beaujolais (note: there can be a wine that appears in multiple regions)
-proof: 12°

I have to find the commands in SQLite3 to get these specific results:

1. Find all the wines that have been collected by the Alsace region (region='Alsace').

2. Find the producers who have harvested all the wines from their region.

Thank you for your help.

(2) By Larry Brasfield (LarryBrasfield) on 2020-04-23 12:20:40 in reply to 1 [source]

You need to study the purpose and effects of the SQL WHERE clause for one of those problems. For the other, you should investigate what GROUP BY and DISTINCT do.

The way to learn the subject matter is to try doing it, before and after studying.

If you have specific questions about why some query you wrote does not yield the results you expect, folks here are likely to help. However, many or most are adverse to doing homework for students who appear too lazy to make a serious effort to do it themselves.