1 / 14

Quick SQL practice

Quick SQL practice. Table Name: Playoffs Fields Player ID Text (3 characters); key field Minutes Number FTM Number FTA Number Rebounds Number Steals Number Blocks Number Total Points Number. More SQL. SELECT. Extracting Data from Tables. The SELECT statement

ziva
Download Presentation

Quick SQL practice

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quick SQL practice • Table Name:Playoffs • Fields • Player IDText (3 characters); key field • MinutesNumber • FTMNumber • FTANumber • ReboundsNumber • StealsNumber • BlocksNumber • Total PointsNumber

  2. More SQL SELECT

  3. Extracting Data from Tables • The SELECT statement • Probably the single most important and widely used SQL command • Syntax: SELECTfields FROMtable WHEREcondition;

  4. A simple SELECT query SELECT Lastname FROM STAR;

  5. More Fields SELECT Lastname, Firstname FROM STAR;

  6. All fields SELECT * FROM STAR;

  7. The WHERE clause • The WHERE clause is the mechanism for filtering out unwanted rows from your results table SELECT Lastname FROM STAR WHERE Lastname=‘Moore’;

  8. AND andOR • More than one condition SELECT Lastname, Firstname FROM Customer WHERE Lastname='Brown' AND Age>20;

  9. OR SELECT Lastname, Firstname FROM customer WHERE Lastname='Brown' OR Age>20; What’s the difference in the results?

  10. A little more nuanced SELECT Lastname, Firstname FROM customer WHERE (Lastname='Brown' AND State='CA') OR (Age>20 AND Sex='F');

  11. ORDER BY • We can sort the results in either ascending or descending order • The default is ascending order. SELECT Lastname, Firstname FROM customer WHERE (Lastname='Brown' AND State='CA') OR (Age>20 AND Sex='F') ORDER BY Firstname;

  12. ORDER BY in descending order SELECT Lastname, Firstname FROM customer WHERE (Lastname='Brown' AND State='CA') OR (Age>20 AND Sex='F') ORDER BY Firstname DESC;

  13. Creating column aliases SELECT LastnameASLName, Firstname FROM customer WHERE (Lastname='Brown' AND State='CA') OR (Age>20 AND Sex='F') ORDER BY Firstname DESC;

  14. LIKE SELECT Lastname FROM customer WHERE Lastname LIKE "B*“;

More Related