Using the simple database schema for healthcare encounters, write SQL queries that will create a table of data responsive to each of the following prompts. For each prompt, pay close attention to which fields are requested, which fields are necessary for filtering and sorting but do not need to appear in the final output, and which tables are necessary to provide the necessary fields.
- Recreate the list from the example prompt, but ensure that each patient is only listed once. That is, produce a list of distinct patients.
- List the names of patients for each procedure type (by billing code). The output should list the billing code first, followed by the patient name. Sort by billing code first, then patient name.
- List the distinct procedure labels for a provider with the specialty of “dermatologist”.
- Produce a count of procedure types for each provider specialty.
- List the names and addresses of all patients who have had an encounter with a provider licensed in California (CA).