Introduction to Subqueries, An Example

Slides:



Advertisements
Similar presentations
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Advertisements

Some Introductory Programming 1. Structured Query Language (SQL) - used for queries. - a standard database product. 2. Visual Basic for Applications -
Introduction to Oracle9i: SQL1 Subqueries. Introduction to Oracle9i: SQL2 Chapter Objectives Determine when it is appropriate to use a subquery Identify.
Introduction to Structured Query Language (SQL)
Queries and query design What are queries? Questions that can be asked of the data in the tables. Questions can draw on one or more tables and can have.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Introduction to Structured Query Language (SQL)
Basic And Advanced SAS Programming
Some Introductory Programming 1. Structured Query Language - used for queries. - a standard database product. 2. Visual Basic for Applications - use of.
1 times table 2 times table 3 times table 4 times table 5 times table
Microsoft Access 2010 Chapter 7 Using SQL.
Table of Contents Quadratic Equation: Solving Using the Quadratic Formula Example: Solve 2x 2 + 4x = 1. The quadratic formula is Here, a, b, and c refer.
Oracle Developer Tools for Visual Studio.NET Curtis Rempe.
Goal: Graph horizontal and vertical lines Eligible Content: A / A
Course Title Database Technologies Instructor: Dr ALI DAUD Course Credits: 3 with Lab Total Hours: 45 approximately.
SSDPS Engagements Put Your IT Investment to Work Streamline Deployment Experience SQL Server 2008 R2.
Creating and Managing Indexes Using Proc SQL Chapter 6 1.
© 2014 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
CASE STUDY: NEW NAMING CONVENTION IN SHAREPOINT David Schlachter.
Unit 4 Queries and Joins. Key Concepts Using the SELECT statement Statement clauses Subqueries Multiple table statements Using table pseudonyms Inner.
Programming in R SQL in R. Running SQL in R In this session I will show you how to: Run basic SQL commands within R.
Unnecessary parenthesis is added to tELTOracleOutput’s generated SQL 1 This is subquery for insert. This query is correct for Oracle command line. Result.
COSC 3480 Projects, Christoph F. Eick 1 Lab COSC 3480 Fall 2000.
SQL Report Writer.  The SQL Report Writer is included with every Appx runtime.  It is intended to be used by end users to create their own reports.
Multiplication Facts Table of Contents 0’s 1’s 2’s 3’s 4’s 5’s 6’s 7’s 8’s 9’s 10’s.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
Subqueries.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Tables Learning Support
Database to HTML and Back again A programmers tale.
to identify the activities of students during their free time. to investigate the method of study among students. to investigate the method of study.
Blood Pressure and Mean Arterial Pressure It’s all about perfusion!
Chapter 7 Subqueries. Chapter Objectives  Determine when it is appropriate to use a subquery  Identify which clauses can contain subqueries  Distinguish.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
DEVRY CIS 336 W EEK 6 G ROUP P ROJECT T ASK 4 Check this A+ tutorial guideline at
Session 1 Retrieving Data From a Single Table
COP 4540 Database Management
Putting tables together
8-5 Factoring by Grouping
(B.P :51) ( B:P52 ).
Times Tables.
Basic Queries Specifying Columns
PROC SQL, Overview.
An Introduction to SQL.
Match-Merge in the Data Step
Noncorrelated subquery
Recursion in SQL Nonlinear and Mutual Recursion.
Demonstrating the Linear Model
Inner Joins.
Create a subset of DPC data
Examining model stability, an example
Combining Data Sets in the DATA step.
مديريت موثر جلسات Running a Meeting that Works
Type your title Type your name Type your major departments
5 The EXCEPT Operator Unique rows from the first result set that are not found in the second result set are selected.
3 Specifying Rows.
Title of Study Presenter names Major department names
Example, Create an analytic file for Nhanes 1999
Trigger %macro check_trigger_run;
Framingham, Exam 5 subset
Unit 3 Review (Calculator)
Fixed Effects estimate using person level data
A new keyword -- calculated
Subqueries.
UNION Operator keywords Displays all rows from both the tables
2 Types of Subqueries.
3 times tables.
6 times tables.
Calculate 9 x 81 = x 3 3 x 3 x 3 x 3 3 x 3 x 3 x 3 x 3 x 3 x =
Hans Baumgartner Penn State University
Presentation transcript:

Introduction to Subqueries, An Example Create an analytic file containing blood pressure values for participants who were eligible for mortality follow-up. Two files involved: nh9.bloodpressure nh9.mortality

nh9.bloodpressure (partial contents)

nh9.mortality (partial contents)

From nh9.mortality documentation

This could be accomplished with SQL if we had a list of sequence numbers in the parens. proc sql; create table bp2 as select mean(bpxsy1,bpxsy2,bpxsy3,bpxsy4) as mnsbp, mean(bpxdi1,bpxdi2,bpxdi3,bpxdi4) as mndbp, seqn from nh9.bloodpressure where calculated mnsbp ne . and calculated mndbp ne . and seqn in (a list of sequence numbers) ; quit; proc means data=bp2; run;

The list of seqn’s can be gotten with a query proc sql; select seqn from nh9.mortality where eligstat=1 ; Putting this in the parentheses makes it a SUBQUERY

Subqueries proc sql; create table bp2 as select mean(bpxsy1,bpxsy2,bpxsy3,bpxsy4) as mnsbp, mean(bpxdi1,bpxdi2,bpxdi3,bpxdi4) as mndbp, seqn from nh9.bloodpressure where calculated mnsbp ne . and calculated mndbp ne . and seqn in (select seqn from nh9.mortality where eligstat=1) ; quit; proc means data=bp2; run;