Chapter 3 slides - Chapter 3 How to retrieve data from a...

This preview shows page 1 - 12 out of 54 pages.

Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 1 Chapter 3 How to retrieve data from a single table
Image of page 1
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 2 Objectives Applied Code and run SELECT statements that use any of the language elements presented in this chapter. Knowledge Distinguish between the base table values and the calculated values in SELECT statements. Describe the use of a column alias. Describe the order of precedence and the use of parentheses for arithmetic expressions. Describe the use of the DISTINCT keyword and the TOP clause. Describe the use of comparison operators, logical operators, and parentheses in WHERE clauses.
Image of page 2
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 3 Objectives (cont.) Knowledge Describe the use of the IN, BETWEEN, and LIKE operators in WHERE clauses. Describe the use of the IS NULL clause in a WHERE clause. Describe the use of column names, aliases, calculated values, and column numbers in ORDER BY clauses. Describe the use of the OFFSET and FETCH clauses in ORDER BY clauses.
Image of page 3
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 4 The simplified syntax of the SELECT statement SELECT select_list FROM table_source [WHERE search_condition] [ORDER BY order_by_list] The four clauses of the SELECT statement SELECT FROM WHERE ORDER BY
Image of page 4
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 5 A simple SELECT statement SELECT * FROM Invoices; (114 rows)
Image of page 5
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 6 A SELECT statement that retrieves and sorts rows SELECT InvoiceNumber, InvoiceDate, InvoiceTotal FROM Invoices ORDER BY InvoiceTotal; (114 rows)
Image of page 6
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 7 A SELECT statement that retrieves a calculated value SELECT InvoiceID, InvoiceTotal, CreditTotal + PaymentTotal AS TotalCredits FROM Invoices WHERE InvoiceID = 17;
Image of page 7
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 8 A SELECT statement that retrieves all invoices between given dates SELECT InvoiceNumber, InvoiceDate, InvoiceTotal FROM Invoices WHERE InvoiceDate BETWEEN '2012-01-01' AND '2012-05-31' ORDER BY InvoiceDate; (101 rows)
Image of page 8
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 9 A SELECT statement that returns an empty result set SELECT InvoiceNumber, InvoiceDate, InvoiceTotal FROM Invoices WHERE InvoiceTotal > 50000;
Image of page 9
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc. Slide 10 The expanded syntax of the SELECT clause SELECT [ALL|DISTINCT] [TOP n [PERCENT] [WITH TIES]] column_specification [[AS] result_column] [, column_specification [[AS] result_column]] ... Five ways to code column specifications All columns in a base table Column name in a base table Arithmetic expression String expression Function
Image of page 10
Murach's SQL Server 2012, C3 © 2012, Mike Murach & Associates, Inc.
Image of page 11

Want to read all 54 pages?

Image of page 12

Want to read all 54 pages?

You've reached the end of your free preview.

Want to read all 54 pages?

  • Fall '14
  • invoice, Microsoft SQL Server, Order of precedence, Mike Murach

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern