SQL. SQL (Structured Query Language) is a standard language for accessing and manipulating databases We have the following "student" table:

Similar documents
Relational Database: Additional Operations on Relations; SQL

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

SQL Basics. Introduction to Standard Query Language

Oracle SQL. Course Summary. Duration. Objectives

Creating QBE Queries in Microsoft SQL Server

Oracle Database: SQL and PL/SQL Fundamentals

David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design and Implementation

Aggregating Data Using Group Functions

Introduction to SQL and SQL in R. LISA Short Courses Xinran Hu

Oracle Database: SQL and PL/SQL Fundamentals

3.GETTING STARTED WITH ORACLE8i

Oracle Database: SQL and PL/SQL Fundamentals NEW

Using Multiple Operations. Implementing Table Operations Using Structured Query Language (SQL)

Database Administration with MySQL

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

Introduction to Microsoft Jet SQL

Ad Hoc Advanced Table of Contents

Welcome to the topic on queries in SAP Business One.

P_Id LastName FirstName Address City 1 Kumari Mounitha VPura Bangalore 2 Kumar Pranav Yelhanka Bangalore 3 Gubbi Sharan Hebbal Tumkur

Learning MySQL! Angola Africa SELECT name, gdp/population FROM world WHERE area > !

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

Advanced Online Media Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

Performing Queries Using PROC SQL (1)

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

To increase performaces SQL has been extended in order to have some new operations avaiable. They are:

Instant SQL Programming

Lecture 25: Database Notes

T-SQL STANDARD ELEMENTS

Excel 2013 Sort: Custom Sorts, Sort Levels, Changing Level & Sorting by Colored Cells

AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C. Y. Associates

Chapter 1 Overview of the SQL Procedure

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY

Oracle Database: SQL and PL/SQL Fundamentals NEW

Rational Software. Getting Started with Rational Customer Service Online Case Management. Release 1.0

In This Issue: Excel Sorting with Text and Numbers

Programming with SQL

Excel 2003: Ringtones Task

Handling Missing Values in the SQL Procedure

Data Mining Commonly Used SQL Statements

Using the SQL Procedure

Netezza SQL Class Outline

Microsoft' Excel & Access Integration

1 Energy Data Problem Domain. 2 Getting Started with ESPER. 2.1 Experimental Setup. Diogo Anjos José Cavalheiro Paulo Carreira

Using SQL Queries in Crystal Reports

DATABASE DESIGN AND IMPLEMENTATION II SAULT COLLEGE OF APPLIED ARTS AND TECHNOLOGY SAULT STE. MARIE, ONTARIO. Sault College

Microsoft Access 3: Understanding and Creating Queries

Financial Data Access with SQL, Excel & VBA

Comp 5311 Database Management Systems. 3. Structured Query Language 1

Access Queries (Office 2003)

SOAL-SOAL MICROSOFT EXCEL 1. The box on the chart that contains the name of each individual record is called the. A. cell B. title C. axis D.

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA

Database Query 1: SQL Basics

Oracle For Beginners Page : 1

Introduction to Proc SQL Steven First, Systems Seminar Consultants, Madison, WI

9.1 SAS. SQL Query Window. User s Guide

SQL Basics for RPG Developers

Inquiry Formulas. student guide

PSU SQL: Introduction. SQL: Introduction. Relational Databases. Activity 1 Examining Tables and Diagrams

- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically

Access 2003 Introduction to Queries

Database Applications Microsoft Access

The software shall provide the necessary tools to allow a user to create a Dashboard based on the queries created.

SQL Server 2008 Core Skills. Gary Young 2011

Using AND in a Query: Step 1: Open Query Design

How To Create A Table In Sql (Ahem)

Katie Minten Ronk, Steve First, David Beam Systems Seminar Consultants, Inc., Madison, WI

SQL SELECT Query: Intermediate

Joins Joins dictate how two tables or queries relate to each other. Click on the join line with the right mouse button to access the Join Properties.

Query 4. Lesson Objectives 4. Review 5. Smart Query 5. Create a Smart Query 6. Create a Smart Query Definition from an Ad-hoc Query 9

Check out our website!

Unit 10: Microsoft Access Queries

Houston Region Diesel Engine Database Minimum System Requirements Installation Instructions Quick Start Guide version 0.1

Reporting with Web Intelligence

Query-by-Example (QBE)

Introduction to SQL: Data Retrieving

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

IINF 202 Introduction to Data and Databases (Spring 2012)

SQL. Short introduction

SQL Examples from Chapters 6&7:

More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan

Oracle Database 11g SQL

Using distributed technologies to analyze Big Data

DBMS / Business Intelligence, SQL Server


WEB DEVELOPMENT COURSE (PHP/ MYSQL)

The Basics of Querying in FoxPro with SQL SELECT. (Lesson I Single Table Queries)

Structured Query Language (SQL)

Trading Dashboard Tutorial

Microsoft Excel 2010 Part 3: Advanced Excel

Excel Formulas & Graphs

1 Structured Query Language: Again. 2 Joining Tables

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Microsoft Access Lesson 5: Structured Query Language (SQL)

Each Ad Hoc query is created by making requests of the data set, or View, using the following format.

Introduction to Proc SQL Katie Minten Ronk, Systems Seminar Consultants, Madison, WI

GCSE Database Projects in Access

Module 9 Ad Hoc Queries

Toad for Data Analysts, Tips n Tricks

Transcription:

SQL SQL (Structured Query Language) is a standard language for accessing and manipulating databases We have the following "student" table: SELECT * Example We want to select all the columns from the "student" table. The asterisk (*) is a quick way of selecting all columns. select * from student; An SQL SELECT Example Now we want to select the content of the columns named "class", "classno" and name from the student table. select class, classno, name from student; WHERE Clause Example Now we want to select only the persons studying in the class "1F" from the student table. select * from student where class='1f'; Page 1

Now we want to select only the persons with class number 1 from the student table. select * from student where classno=1; Now we want to select only the persons who pass Chinese from the student table. select * from student where chinese>=50; Now we want to select only the persons who pass english and maths from the student table. select * from student where english>=50 and maths>=50; Now we want to select only the persons who pass chinese or maths from the student table. select * from student where chinese>=50 or maths>=50; Page 2

ORDER BY Example Now we want to select all the persons from the table above, however, we want to sort the persons by their name. select * from student order by name; ORDER BY DESC Example Now we want to select all the persons from the table above, however, we want to sort the persons descending by their name. select * from student order by name desc; MAX() Example Now we want to find the highest mark of chinese from the student table select max(chinese) as highest_chinese from student; as highest_chinese is used to highest_chinese as the column name of the result. MIN() Example Now we want to find the lowest mark of maths from the student table select min(maths) as lowest_maths from student; Page 3

MIN() Example Now we want to find the lowest mark of maths from the student table select min(maths) as lowest_maths from student; SUM() Example Now we want to find the sum of all chinese fields. select sum(chinese) as total_chinese from student; AVG() Example Now we want to find the average mark of chinese. select avg(chinese) as average_chinese from student; Now we want to find the average mark of chinese in 1F class. select avg(chinese) as 1F_average_chinese from student where class='1f'; COUNT(column_name) Example Now we want to count the number of students who pass chinese" select count(name) as no_pass_chinese from student where chinese>=50; The result of the SQL statement above will be 4, because 4 students pass chinese. Page 4

Group by Example We can use group by to find sum(), min(), max(),count(),avg() according to a specific field. The following SQL command is used to display the average of Chinese mark for each class. select class, avg(chinese) from student group by class; The result is: class Expr1001 1A 73 1B 72 1C 55.5 2A 64 2B 71 The following SQL command is used to display the number of students whose math mark is greater than or equal to 50 for each class. select class, count(name) from student where Math>=50 group by class; The result is: class Expr1001 1A 2 1B 1 2A 1 2B 2 Reference: http://www.sqlzoo.net/ http://www.w3schools.com/sql/default.asp Page 5