Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Database Foundations Stage 7: SQL Calculating, Aggregating and Other Functions Launched

The latest stage of database foundations has been launched. It's called SQL Calculating, Aggregating and Other Functions.

SQL has various functions to perform arithmetic operations similar to what you would see in a spreadsheet application. Other functions help to group data together in more meaningful ways, while others help you do more complex filtering of your information.

Enjoy!

4 Answers

Yesss! Ive already started. I have ran into a minor problem. I downloaded the add-on file for the database, but when I try to open it, I get an error that says it is not a workbench document.

Any suggestions?

Thanks!

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

Can you open it in Sublime or TextMate?

Does it start with...

DROP DATABASE IF EXISTS treehouse_movie_db;
CREATE DATABASE treehouse_movie_db;
USE treehouse_movie_db;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

Let me know.

Chase Lee
Chase Lee
29,275 Points

Same problem. Can't tell exactly but it look the same.

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

I just downloaded it and ran it. With no problems.

Do you have a specific error or a screenshot of your problem.

In your mysql workbench after opening the connection to your database (where you start queries) Do the following

File -> Open -> Open SQL Script. And then browse for the .sql file that was provided.

Additionally you can use the terminal to run the SQL script (which is better in my opinion for large scripts as it crashes the GUI less)

Using this command:

mysql -u root -p < path_to_script.sql

This will log you in as the root user, and ask for it's password, then it will execute the file you linked. Not sure if this works on windows, but should work on mac and linux just fine.

Chase James You are opening a model file, Press Ctrl Shift O, or file -> open SQL script, NOT a model..

Chase Lee
Chase Lee
29,275 Points

When do I do that? The file stuff doesn't work here are my options.

Chris James Double click on your localhost database to start querying. You want to be in the query editor, not in the main home page. Login to your database to the point where you would start writing SQL queries as you have done in past tutorials. You can then Open the SQL script in that screen.

EDIT: Meant to reference Chase James

Chase Lee
Chase Lee
29,275 Points

Okay. Tried it and worked. Thanks so much Richard Crawford-Wilson!

Andrew Chalkley , you know you're awesome right?

Joss Daniels
Joss Daniels
59,875 Points

On the videos I get NaN:NaN on the thing that usually shows the time of the video and I can't click through to certain parts of the videos?

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

If it's still happening, send a screenshot to help@teamtreehouse.com and they'll help you out and look in to it.