-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nate Allen
committed
May 9, 2012
1 parent
7078c15
commit a2c3460
Showing
4 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<h3>Ch4-1 : Count</h3> | ||
<p> | ||
Now we're going to move on to analysis of large data. Our tables here are pretty small (less than 20 rows), but the techniques learned will be valuable when working with millions of rows. | ||
Now we're going to move on to analysis of large data. Our tables here are pretty small (less than 20 rows), but the techniques learned will be valuable when working with larger sets of information | ||
<br /> <br /> | ||
The foundation of your standard aggregate select statement is the <code>count</code> function. As you might expect it returns the number of rows in a table. We can further refine the search by adding a where clause. This will then go out and retrieve a count for all rows matching the where clause. Try the two queries below. | ||
<br /><code>select count(*) from students</code> | ||
<br /><code>select count(*) from students where fname like 'S%'</code> | ||
<br / > | ||
<br /> | ||
<code>select count(*) from students</code> | ||
<br /> | ||
<code>select count(*) from students s where s.fname like 'S%'</code> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<h3>Ch4-2 : Count (cont.)</h3> | ||
<p> | ||
One limitation of the straight forward count, is that it doesn't allow you to associate data with other columnts. To further assist in data analysis, we can employ the <code>group by</code> clause. | ||
One limitation of the straight forward count is that it doesn't allow you to associate data with other columns. To further assist in data analysis, we can employ the <code>group by</code> clause. | ||
<br /> <br /> | ||
This will allow us to not just select the count, but other columns as well. For instance, try finding the count of course registrations based on semester below | ||
<br /><code>select semester,count(*) from course_fcts group by semester</code> | ||
<br / > | ||
It is important to note, that for each column in your select statement, you must include that column in the group by clause. | ||
Note: For each column in your select statement, you must include that column in the group by clause. | ||
</p> |