IT: Count for column in SQL

How to perform a count in SQL:

Example: How many ingredients are in each ice cream flavor?

Select Ice_cream_ID, count (Ingredient_ID) FROM RECIPE group by Ice_cream_ID;

Output:

SQL> Select Ice_cream_ID, count (Ingredient_ID) FROM RECIPE group by Ice_cream_ID;

ICE_CREAM_ID COUNT(INGREDIENT_ID)

———— ——————–

101                    5

201                    3

211                    1

311                    1

321                    1

405                    1

406                    1

407                    1

520                    1

540                    4

545                    2

11 rows selected.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s