1 / 8

Interpreting SQL Code

Interpreting SQL Code. SQL (The language used to query a database). S is used to specify the you want to include. F is used to specify the the selected fields are coming from.

gypsy
Download Presentation

Interpreting SQL Code

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. Interpreting SQL Code

  2. SQL (The language used to query a database) • S is used to specify the you want to include. • F is used to specify the the selected fields are coming from. • W is used to used to narrow down the data prior to being displayed. • O is used to specify how the records (in ascending or descending order), as well as the sort order. • I specifies that two or more tables are and it also specifies the field that forms the between the tables.

  3. S the following fields from the Employees table: Last Name, Title and Salary. • The used to narrow down the records is where the title is “Sales Representative.” • The results should be in descending order (high to low number order) based on salary. • All of the fields in the query come from the Employees table.

  4. SELECT Max(Employees.Salary) AS MaxOfSalary, Min(Employees.Salary) AS MinOfSalary, Avg(Employees.Salary) AS AvgOfSalary, StDev(Employees.Salary) AS StDevOfSalary FROM Employees; Select the Salary field from the Employees table (4 times). Find the maximum salary, the minimum salary, the average of salaries and the standard deviation of salaries.

  5. Select the following fields from the Customers table: Company Name, City and Country. • The criteria used to narrow down the records is where the country begins with U (it does not matter what comes after the U as long as the first letter of the country is a U). • All of the fields in the query come from the Customers table.

  6. All of the fields in the query come from either the Customers table or the Orders table. The Customers and Orders tables are joined together by the common field of Customer ID (Inner Join signifies this). Select the following fields from the Customers table: Customer ID and Company Name. Select the following fields from the Orders table: Order Date and Shipped Date. The criteria used to narrow down the records is that the company name should match “B’s Beverages”.

  7. O is used to specify how the records should be sorted (in ascending or descending order), as well as the sort order. • F uses the city field and the records are sorted in alphabetical order by city (order by defaults to ascending order) • If there happen to be multiple entries from the same city, a (descending order by last name)

More Related