2021 fall cs61a lab13

网址 https://inst.eecs.berkeley.edu/~cs61a/fa21/lab/lab13/

    .read data.sql


    CREATE TABLE bluedog AS
      SELECT color, pet FROM students WHERE color = 'blue' AND pet = 'dog';

    CREATE TABLE bluedog_songs AS
      SELECT color, pet, song FROM students WHERE color = 'blue' AND pet = 'dog';


    CREATE TABLE smallest_int_having AS
      SELECT time, smallest FROM students group by smallest HAVING COUNT(*) = 1;


    CREATE TABLE matchmaker AS
      SELECT s1.pet, s1.song, s1.color, s2.color
      FROM students as s1, students as s2
      WHERE s1.pet = s2.pet and s1.song = s2.song and s1.time < s2.time;

    CREATE TABLE sevens AS
      SELECT s.seven
      FROM students AS s, numbers AS n 
      WHERE s.time = n.time and s.number = 7 and n.'7' = "True";


    CREATE TABLE avg_difference AS
      SELECT round(avg(abs(number - smallest)))
      FROM students;
posted @ 2022-05-01 23:23  天然气之子  阅读(339)  评论(0编辑  收藏  举报