Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Sorting output.

Slides:



Advertisements
Similar presentations
Database Fundamentals
Advertisements

Sorting Rows. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Construct a query to sort a results set in ascending.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Physical.
Microsoft® Access® 2010 Training
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Self-joins,
Microsoft Enterprise Consortium Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Database Fundamentals Defining.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Create Student-Team.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Aggregate.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals The Data.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Data.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Evaluating.
Instructor: Craig Duckett CASE, ORDER BY, GROUP BY, HAVING, Subqueries
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Greenhouse Database.
Databases Tutorial 2 Further Select Statements. Objectives for Week Data types Sort retrieved data Formatting output.
Access Lecture 1 Database Overview and Creating Tables Create an Employee Table.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Type II (Correlated)
Microsoft Access 2010 Chapter 7 Using SQL.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Introduction.
PHP and SQL Server: Queries IST2101. Project Report 4 SQL Queries Due Sunday, 4/5 at 11:59pm Instructions on how to access team webspace and SQL database.
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Using two.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals SQL Server.
Chapter 2 Basic SQL SELECT Statements
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
1 Copyright © 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Test.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals SELECT … FROM.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Nested aggregate.
EXAM-2 OVERVIEW Aliya Farheen
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Aggregating.
Views Lesson 7.
SQL for Data Retrieval. Running Example IST2102 Data Preparation Login to SQL server using your account Select your database – Your database name is.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals SELECT … FROM.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Physical.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database.
Database Applications – Microsoft Access Lesson 7 Designing Custom Reports Updated 11/13 27 Slides in Presentation.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Logical operators.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL In-Line Subquery.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Equi-Join One-sided.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen October 29,2015.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Set Operators:
Working with Columns, Characters, and Rows. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Apply the concatenation.
The Rent-A-Dress Database
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals WHERE clause.
Lesson 4: Querying a Database. 2 Learning Objectives After studying this lesson, you will be able to:  Create, save, and run select queries  Set query.
1 Connecting to a Database Server. 2 We all have accounts, with a single database each, on a Microsoft SQL Server on the USF network: allman.forest.usf.edu.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL The relational.
PREPARED BY: PN. SITI HADIJAH BINTI NORSANI. LEARNING OUTCOMES: Upon completion of this course, students should be able to: 1. Understand the structure.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Data.
Create Views Using a Graphical Designer Database Administration Fundamentals LESSON 2.3b.
Create Views Using T-SQL Database Administration Fundamentals LESSON 2.3a.
1 Copyright © 2007, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
1 Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Using the Set Operators
Dumps4Download Oracle 1z0-051 Exam Dumps - Oracle 1z0-051 Exam Dumps Questions
Database Applications – Microsoft Access
Using the Set Operators
Microsoft Enterprise Consortium Type I Subquery
Database Fundamentals
Access: SQL Participation Project
Introduction To Structured Query Language (SQL)
From and Report.
Using the Set Operators
Presentation transcript:

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Sorting output (ORDER BY) Column aliases Concatenating columns Calculated columns 1 Microsoft Enterprise Consortium Microsoft Enterprise Consortium: Microsoft Faculty Connection/Faculty Resource Center

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium What you’ll need … Log in to MEC for this lesson and into MSSMS (Microsoft SQL Server Management Studio). ◦Be sure to select your account ID under Database in the Object Explorer pane, similar to the example shown here. If there is something besides the topics for this lesson that you’re not familiar with, please review earlier lessons in this SQL Fundamental series. 2

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Sorting output The more data your query displays the more likely you’ll want to sort the output. ORDER BY – You add the ORDER BY clause to the SELECT statement to sort output. SELECT,, FROM WHERE = ORDER BY, ; The trick is to remember to not use the word SORT but ORDER. 3

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Sort output from the Student-Team database List students and their team ID. Sort by team ID. /* List students and their team ID. Sort by team ID. */ select std_teamID, stdmajor, stdfname, stdlname from students order by std_teamID ; 4

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Sort by more than one column. List students by team and major. /* List students and their team ID. Sort by team ID and major. */ select std_teamID, stdmajor, stdfname, stdlname from students order by std_teamID, stdmajor ; /* Another way to identify which columns to sort by using numbers. */ select stdfname, stdlname, stdmajor, std_teamID from students order by 4, 3 ; 5

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Column aliases improve readability Columns in the output display can show standard text rather than field names. /* Use column aliases column headings in output. */ select std_teamID "Team", stdmajor "Major", stdfname "First Name", stdlname "Last Name" from students order by std_teamID, stdmajor; 6

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Combine columns into a single output column Sometimes you can improve output readability by combining columns, also known as concatenated columns. 7 /* Combine 2 columns into one (concatenate columns). */ select std_teamID "Team", stdmajor "Major", stdfname + ' ' + stdlname "Student" from students order by 1, 2; select std_teamID "Team", stdmajor "Major", stdlname + ', ' + stdfname "Student" from students order by 1, 2, 3;

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Creating a calculated column The concatenated column we just created in one example of a calculated column. You can also actually do calculations. 8 /* Add a calculated column. */ select eval_id, eval_score_id, eval_item_id, score, score *.1 "Points Earned" from eval_items_scores order by eval_id, eval_score_id, eval_item_id;

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium What was covered … Sorting query output using ORDER BY. Using column aliases to make easy-to-read column headings, Using calculated columns. ◦Concatenating text columns into a single display column. ◦Calculating values and displaying them. 9

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Resources Microsoft Faculty Connection—Faculty Resource Center Microsoft Transact-SQL Reference AdventureWorks Sample Database 10