Skip to content

Commit

Permalink
More presentation polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Allen committed May 9, 2012
1 parent 7078c15 commit a2c3460
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
14 changes: 7 additions & 7 deletions app/controllers/sqlcons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SqlconsController < ApplicationController
# GET /sqlcons
# GET /sqlcons.json
def index
session[:maxsec] = Sqlcons.maximum(:sec).where("ch = 1")
session[:maxsec] = Sqlcons.maximum(:sec, :conditions => "ch = 1")
session[:tutch] = 1
session[:tutsec] = 1
render :index
Expand Down Expand Up @@ -35,7 +35,7 @@ def fetchquery
pickdisplay
render :show
end

#TODO: Fix refresh bug where user can martch entirely through lesson.
#Increments session parameters if user wants to advance lesson.
def nextlesson
cur_sec_max = Sqlcons.maximum(:sec, :conditions => "ch = " + session[:tutch].to_s)
Expand All @@ -54,13 +54,13 @@ def nextlesson
session[:tutch] += 1
session[:tutsec] = 1
end
@qstatus = 3
@qresults = nil
if user_done
render :file => Rails.root + "app/views/sqlcons/tutorials/congratulations.html"
render :file => Rails.root + "app/views/sqlcons/tutorials/congratulations.html"
else
pickdisplay
render :show
@qstatus = 3
@qresults = nil
pickdisplay
render :show
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/sqlcons/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<!--Text area for next query-->
<%= form_tag(sqlcons_fetchquery_path, :method => "get") do %>
<%= text_area_tag(:q, "select * from courses",:size=>"90x3") %>
<%= text_area_tag(:q, "", :size=>"90x3") %>
<br />
<%= submit_tag("querydb", :onclick=>"this") %>
<% end %>
Expand Down
9 changes: 5 additions & 4 deletions app/views/sqlcons/tutorials/tut4-1.html
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>
4 changes: 2 additions & 2 deletions app/views/sqlcons/tutorials/tut4-2.html
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>

0 comments on commit a2c3460

Please sign in to comment.