Skip to content
group

introducing group by


ROUTE (copy)
1
ROUTEID
STARTPOINT
FINISHPOINT
ESTIMATEDMINS
KMS
ROUTETYPE
RATING
1
1
Shiel Bridge
Glen More
480
23
Mountain
5
2
2
Aberdour
Anstruther
600
44
Coastal
4
3
3
Rackwick
Rackwick
180
12
Coastal
2
4
4
Kelty
Loch Glow
90
5
Forest
1
5
5
Fort William
Steall Falls
210
8
Hill
4
6
6
Pitlochry
Blair Atholl
175
11
Forest
2
There are no rows in this table
6
Count

Suppose there was a functional requirement to :
display a list of route types
The following code could be used
select routetype from route
The results would show multiple copies of the same value.
The group by clause gathers together rows with identical values and returns them as a single group (row)
select routetype from route
group by routetype
Loading…
So the two coastal values and the two forest values are combined to form a single group (row) for each.
Notice 4 rows are returned rather than 6.
Using group by is a way of displaying the unique values in a column

Using group by

Display a list of the unique rating values


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.