#SQL #subquery # BigQuery
A subquery is a query that appears inside another query statement.
Example: Identify which food industries have the highest number of complaints/recalls from the FDA public database and find out which of these complaints led to hospitalizations.
The first step is to find which food industries have the highest number of complaints.
Open BigQuery Console and in your project bigquery-public-data, select the fda_food dataset and the food-events table.


This is a table preview

Write a query to find which products-industry-name has the highest number of complaints

Write a query to find out which of these complaints led to hospitalizations:

The subquery (in yellow) is a query nested in another query to find which products-industry-name has the highest number of complaints. Among these, the main query selects those that led to hospitalizations. The logical AND operator displays a record if all the conditions are TRUE; the LIKE operator searches for a specific pattern in a column: it returns all products_industry_name in the outcomes column that contain the pattern Hospitalization).








































