To get a general idea of how grouping works in SQL, let's create a small table quickly and then use group function to see what happens.
We have now created fruits table with some entries in it.
This is how this table looks like...
We have intentionally added some Null entry in the column to see how they are going to be grouped.
Data provided to us often includes null values too and let's see how grouping affects on these values.
GROUP BY command is going to let us know how many items in the column for which groups are formed. So there are 4 groups in the column. Orange, Mango, Apple and Null
If we further add COUNT function to see how many items in each group...
Now we can clearly see how many records in each group.
It is important to note that Null is considered as a group and it has 3 records.
No comments:
Post a Comment