Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Query Live Database

Query Live Database

822420b9b544e30b558619eb269996cf?s=128

Christina Koch

August 23, 2016
Tweet

More Decks by Christina Koch

Other Decks in Programming

Transcript

  1. QUERIES  FOR  A  LIVE  STUDENT  DB   used  in  conjunc+on

     with  www.datacarpentry.org/sql-­‐ecology-­‐lesson/  
  2. Fill  out  your  cards   •  Name:  first  name  

    •  Height:  in  INCHES   •  Dept  (department):  close  enough  (just  pick   one  if  you  don’t  have  a  home  department)   •  DoC  (Dog  or  Cat):  Dog,  Cat,  Both,  Neither,  or   leave  blank  
  3. None
  4. SELECT name
 FROM students

  5. select name,name
 from StUdEnTs

  6. SELECT name, height
 FROM students

  7. SELECT name, 
 height*2.54 FROM students

  8. None
  9. SELECT name, dept
 FROM students
 WHERE height <= 66

  10. SELECT name, dept
 FROM students
 WHERE DoC 
 IN (‘Dog’,

    ‘Cat’)
  11. SELECT name, 
 height*2.54 FROM students
 ORDER BY height

  12. SELECT name, 
 height*2.54 FROM students
 WHERE height >= 68


    ORDER BY name DESC
  13. None
  14. SELECT COUNT(*)
 FROM students

  15. SELECT COUNT(*)
 FROM students
 GROUP BY DoC

  16. SELECT MAX(height), 
 MIN(height)
 FROM students
 GROUP BY DoC