Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals SELECT … FROM.

Slides:



Advertisements
Similar presentations
Database Fundamentals
Advertisements

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Physical.
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.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
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.
Access Tutorial 1 Creating a Database
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Greenhouse Database.
Concepts of Database Management Sixth Edition
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.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
SQL for Data Retrieval. Save your SQL Scripts When working with SQL Management Studio, you should keep saving your scripts as a.sql file to somewhere.
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Introduction.
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.
ASP.NET Programming with C# and SQL Server First Edition
Database Applications – Microsoft Access Lesson 9 Designing Special Queries Updated 4/11.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
1 Working with MS SQL Server Textbook Chapter 14.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Test.
Database Introduction Section 14 – Lesson 01 Use the student note section below for further explanation of the slide content.Use the student note section.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Nested aggregate.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Aggregating.
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.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Sorting output.
Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database.
Microsoft ® Office Excel 2003 Training Using XML in Excel SynAppSys Educational Services presents:
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.
In this session, you will learn to: Use functions to customize the result set Summarize and group data Objectives.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
SQL for Data Retrieval. Save your SQL Scripts When working with SQL Management Studio, you should keep saving your scripts as a.sql file to somewhere.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Advanced SQL Equi-Join One-sided.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Set Operators:
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
Agenda for Class 2/20/2014 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)
CS 111 – Nov. 8 Databases Database Management Systems (DBMS) Structured Query Language (SQL) Commitment –Please review sections 9.1 – 9.2.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals WHERE clause.
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.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
COMPREHENSIVE Access Tutorial 1 Creating a Database.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Data.
Create Views Using T-SQL Database Administration Fundamentals LESSON 2.3a.
Understanding Core Database Concepts Lesson 1. Objectives.
Controlling User Access
Controlling User Access
Connect to SQL Server and run select statements
Access Tutorial 1 Creating a Database
Chapter 1 Introduction.
Current outstanding balance
Microsoft Enterprise Consortium Type I Subquery
Access Tutorial 1 Creating a Database
Chapter 1 Introduction.
Database Fundamentals
Chapter 1 Introduction.
Chapter 1 Introduction.
Using SQL*Plus.
Access Tutorial 1 Creating a Database
Access Tutorial 1 Creating a Database
Understanding Core Database Concepts
Presentation transcript:

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals SELECT … FROM … 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 … For this and other SQL lessons, you need a user account from the Microsoft Enterprise Consortium. Get this account from your instructor. 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. 2

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium AdventureWorks Microsoft provides an example database called AdventureWorks (AW). For the time being, only a subset of tables from this database will be used. Shown here is the data model for the HR portion of the AW database. An additional table is included from the PERSON section of the database. 3

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Student-Teams 4 This database keeps information about students, the teams they are assigned to and the peer evaluations students complete for their teammates at the end of a project.

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SELECT … FROM The SELECT statement has several components but let’s start with only the FROM clause. A simple SELECT statement has the following format … SELECT,, … FROM ; The angle brackets indicate words that change depending on what data we want to see. Recommendation: Keep all the SQL commands you write for a lesson in a text file using Notepad. Do the same for SQL you write or assignments. 5

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Query the Student-Team database Open a Query pane (New Query). Type the SQL in Notepad then copy/paste into the query pane. Add a comment. Let’s start off by seeing what teams there are. Enter two columns (teamID and team_name) in the SELECT clause. List the table name in the FROM clause. Execute the query. /* Show teams */ select teamid, team_name from teams; 6

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Query students & teams Query the STUDENTS table and show the ID and full name of each student. /* List students */ select stdid, stdfname, stdlname from students; Query the TEAMS table and show all columns. The asterisk is a “wild card” that means to show all columns without listing them by name. /* List all columns in TEAMS */ select * from teams; 7

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Query tables in AdventureWorks (AW) The AdventureWorks database is not in your account. To query tables in other accounts, you need to add more information to the table name in the FROM clause. In SQL below we specify the database or account name and the schema databasename.schema.tablename /* List departments in AdventureWorks */ Select DepartmentID, Name, GroupName From AdventureWorks2008.HumanResources.Department; Show information about shifts. /* List shift data AdventureWorks */ Select ShiftID, Name, StartTime, EndTime From AdventureWorks2008.HumanResources.Shift; 8

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Count rows in a table How many students are there? /* Count students */ select count(*) from students; How many records are there in AW’s EMPLOYEE table? /* Count employee records in AW */ select count(*) from AdventureWorks2008.HumanResources.Employee; 9

Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium What was covered … SELECT … FROM … SELECT * FROM … SELECT Count(*) FROM ….. Databasename = database or account name Schema = container of database objects 10

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 11