Ordering Allergies by Popularity from Patient Records

Your task is to write an SQL query to fetch all allergies from the patients table. The data should be ordered by the popularity of each allergy. Ensure you exclude any NULL values from your result.

Concepts to Remember

  • Grouping and Aggregating: In many cases, we're interested not just in the individual rows of a table, but in aggregations of rows. The GROUP BY clause groups rows that have the same values in specified columns into summary rows.

  • Ordering Results: The order in which rows are returned in a result set can be specified using the ORDER BY clause. You can sort the results by a column in ascending or descending order.

  • Filtering Data: The WHERE clause is used to filter records based on specific conditions. Pay attention to how you can use it to exclude specific values, such as NULL.

The column names must be allergies and total_diagnosis

Good luck with your query!

Adding your container request
Getting your dedicated container
Connecting to your container
Setting up your editor
Finalizing your playground
TerminalEditorBrowser