Access - 1 Table Query (View) FormReport Database Application Basic Database Objects Relationships among Access Database Objects A saved SELECT query is.

Slides:



Advertisements
Similar presentations
TURKISH STATISTICAL INSTITUTE 1 /34 SQL FUNDEMANTALS (Muscat, Oman)
Advertisements

 Database is SQL1.mdb ◦ import using MySQL Migration Toolkit 
1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
1 Minggu 4, Pertemuan 8 SQL: Data Manipulation (Cont.) Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
View Sen Zhang. Views are very common in business systems users view of data is simplified a form of security - user sees only the data he/she needs to.
Chapter 6 SQL: Data Manipulation Cont’d. 2 ANY and ALL u ANY and ALL used with subqueries that produce single column of numbers u ALL –Condition only.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Chapter 2 Basic SQL SELECT Statements
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Introduction to Relational Database and SQL Minder Chen CSU Channel Islands
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
Microsoft Access 2010 Building and Using Queries.
Agenda TMA01 M876 Block 3 – Using SQL Structured Query Language - SQL A non-procedural language to –Create database and relation structures. –Perform.
CSC271 Database Systems Lecture # 12. Summary: Previous Lecture  Row selection using WHERE clause  WHERE clause and search conditions  Sorting results.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) Structured Query Language Introduction to SQL Structured Query Language.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
New SQL Commands in Oracle. INNER JOINs NATURAL JOIN Perform JOIN based on like columns in two tables. The Like columns must be of the same name and data.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
SQL Data Manipulation II Chapter 5 CIS 458 Sungchul Hong.
SQL: Data Manipulation I Chapter 5 CIS 458 Sungchul Hong.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
IST 210 SQL Todd Bacastow IST 210: Organization of Data.
Structured Query Language
Queries SELECT [DISTINCT] FROM ( { }| ),... [WHERE ] [GROUP BY [HAVING ]] [ORDER BY [ ],...]
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
1/18/00CSE 711 data mining1 What is SQL? Query language for structural databases (esp. RDB) Structured Query Language Originated from Sequel 2 by Chamberlin.
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.
SQL SELECT Getting Data from the Database. Basic Format SELECT, FROM WHERE (=, >, LIKE, IN) ORDER BY ; SELECT LastName, FirstName, Phone, City FROM Customer.
Course title: Database-ii Chap No: 03 “Advanced SQL” Course instructor: ILTAF MEHDI.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
WEEK# 12 Haifa Abulaiha November 02,
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
# 1# 1 QueriesQueries How do we ask questions of the data? What is SELECT? What is FROM? What is WHERE? What is a calculated field? Spring 2010 CS105.
Drill Consider the following tables with the following fields: Student: FName, LName, StudentID, Age, Yr, Course Grades: ID, P1, P2, P3 1.Display the.
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
به نام خدا SQL QUIZ جوانمرد Website: ejavanmard.blogfa.com.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
 CONACT UC:  Magnific training   
1 Introduction to Database Systems, CS420 SQL JOIN, Group-by and Sub-query Clauses.
Database Design lecture 3_2 Slide 1 Database Design Lecture 3_2 Data Manipulation in SQL Simple SQL queries References: Text Chapter 8 Oracle SQL Manual.
13 Copyright © 2004, Oracle. All rights reserved. Migrating SQL Statements.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
Writing Basic SQL SELECT Statements
The Database Exercises Fall, 2009.
SQL FUNDAMENTALS CDSE Days 2018.
Writing Basic SQL SELECT Statements
(SQL) Aggregating Data Using Group Functions
Chapter Name SQL: Data Manipulation
Chapter 4 Summary Query.
Aggregating Data Using Group Functions
Introduction To Structured Query Language (SQL)
Index Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23,
Contents Preface I Introduction Lesson Objectives I-2
分组函数 Schedule: Timing Topic 35 minutes Lecture 40 minutes Practice
Manipulating Data Lesson 3.
Restricting and Sorting Data
Presentation transcript:

Access - 1 Table Query (View) FormReport Database Application Basic Database Objects Relationships among Access Database Objects A saved SELECT query is officially called View in SQL. QUERY in Access can be SELECT, INSERT, UPDATE, or DELETE. You can create a query against a table or a query. You can create a form or report against a table or a query.

Access - 2 Date Literal Format Oracle SQL: SELECT D_O_H, F_NAME, L_NAME FROM INSTRUCTOR WHERE D_O_H < '01-JAN-90' ORDER BY D_O_H; Access SQL: SELECT D_O_H, F_NAME, L_NAME FROM INSTRUCTOR WHERE D_O_H < #01/01/1990# ORDER BY D_O_H;

Access - 3 String Wild Card Search Oracle SQL: SELECT NAME, CITY FROM STUDENT WHERE CITY LIKE 'FAIR%'; Access SQL: SELECT NAME, CITY FROM STUDENT WHERE CITY LIKE 'FAIR*';

Access - 4 String Wild Card Search Oracle SQL: SELECT NAME, CITY FROM STUDENT WHERE CITY LIKE 'FAIR_ _ _'; Access SQL: SELECT NAME, CITY FROM STUDENT WHERE CITY LIKE 'FAIR??? ';

Access - 5 Sort By Clause Oracle SQL: SELECT L_NAME, F_NAME, SALARY * 0.1 AS BONUS FROM INSTRUCTOR ORDER BY BONUS DESC, L_NAME; Access SQL: (cannot use alias column name in Order By clause) SELECT L_NAME, F_NAME, SALARY * 0.1 AS BONUS FROM INSTRUCTOR ORDER BY 3 DESC, L_NAME;

Access - 6 String Concatenation Oracle SQL: SELECT L_NAME | | ', ' | | F_NAME | | ' ' | | M AS NAME FROM INSTRUCTOR; Access SQL: (use & instead of || for string concatenation) SELECT L_NAME & ', ' & F_NAME & ' ' & M AS NAME FROM INSTRUCTOR;

Access - 7 Substring Function Oracle SQL: SELECT SUBSTR(DIV_NAME,1,4) "SUBS" FROM DIVISION; Access SQL: (use LEFT string function) SELECT Left(DIV_NAME,4) as SUBS FROM DIVISION;

Access - 8 Trunc() vs Round() Oracle SQL: SELECT DIV, TRUNC(AVG(SALARY)/52, 2) AS AVG_SAL FROM INSTRUCTOR GROUP BY DIV HAVING COUNT(*) > 1 ORDER BY DIV; Access SQL: (use & instead of || for string concatenation) SELECT DIV, Round(AVG(SALARY)/52,2) as AverageSalary FROM INSTRUCTOR GROUP BY DIV HAVING COUNT(*) > 1 ORDER BY DIV;

Access - 9 Date Function Oracle SQL: SELECT I_NO, TRUNC(MONTHS_BETWEEN(SYSDATE, D_O_B)/12, 0) AS AGE FROM INSTRUCTOR; Access SQL: (Date function) SELECT I_NO, ROUND(DateDiff("m", D_O_B, Now)/12, 0) AS AGE FROM INSTRUCTOR;

Access - 10 Insert Statement Oracle SQL: INSERT INTO INSTRUCTOR (I_NO, L_NAME, M, F_NAME, SALARY) VALUES (60, 'SMITH', 'F', 'BOB', 60000); Access SQL: (The Insert statement above will work in Access; however, when you switch to design mode, the Insert statement will be changed to the following statement by Access automatically) INSERT INTO INSTRUCTOR ( I_NO, L_NAME, M, F_NAME, SALARY ) SELECT 60 AS Expr1, 'SMITH' AS Expr2, 'F' AS Expr3, 'BOB' AS Expr4, AS Expr5;

Access - 11 Count and Distinct Statement Limitation Oracle SQL: SELECT COUNT(DISTINCT CITY) FROM STUDENT; -- Answer: 3 (excluded NULL value records from the count) Access SQL (Include NULL value; cannot use distinct and Count together) You have to use the SQL view to enter the distinct keyword. It will not work in the Design view. SELECT DISTINCT (CITY) FROM STUDENT;

Access - 12 How to count distinct values Create the first query using distinct and save it as DistinctTitles Create the second query against the DistinctTitles query. Use count function in this second query.

Access - 13 SQL Join Oracle: (This works in Access as well) SELECT TITLE, COURSE.C_ID, LOCATION, START_DATE FROM COURSE, OFFERING WHERE COURSE.C_ID = OFFERING.C_ID ORDER BY TITLE; Access SQL and SQL-92 Standard: (May not work in Oracle SQL*Plus) SELECT Title, COURSE.C_ID, LOCATION, START_DATE FROM COURSE INNER JOIN OFFERING ON COURSE.C_ID = OFFERING.C_ID ORDER BY TITLE;