{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "skip" } }, "source": [ "NOTE:\n", "-----\n", "\n", "Please run the below cells first before proceeding- you'll need them soon!" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "slideshow": { "slide_type": "skip" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The sql extension is already loaded. To reload it, use:\n", " %reload_ext sql\n" ] }, { "data": { "text/plain": [ "u'Connected: None@dataset_1.db'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%load_ext sql\n", "%sql sqlite:///dataset_1.db" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Activity 3-3\n", "------------\n", "Quantifiers, NULLs, and Outer Joins" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Exercise #1\n", "-----------\n", "\n", "Recall that the tables we just looked at:\n", "\n", "`bagel`, which describes types of bagels made by the different bagel companies:\n", "> * name STRING\n", "> * price FLOAT\n", "> * made_by STRING\n", "\n", "And `purchase`:\n", "> * bagel_name STRING\n", "> * franchise STRING\n", "> * date INT\n", "> * quantity INT\n", "> * purchaser_age INT\n", "\n", "Where `purchase.bagel_name` references `bagel.name` and `purchase.franchise` references `bagel.made_by`.\n", "\n", "**Can you find out if there were any purchases of products not on one of the company's official lists (i.e. the `bagel` table), using a single SQL query?**\n", "\n", "Write your query here:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Done.\n" ] }, { "data": { "text/html": [ "
Official List Name | \n", "Purchase Item | \n", "Bought From | \n", "date | \n", "quantity | \n", "
---|---|---|---|---|
None | \n", "Drugs | \n", "BAGEL CORP | \n", "7 | \n", "1000 | \n", "