THE SQL SELECT STATEMENT QUESTIONS

Similar documents
Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

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

Displaying Data from Multiple Tables. Chapter 4

Chapter 1. Writing Basic. SQL Statements

3.GETTING STARTED WITH ORACLE8i

Producing Readable Output with SQL*Plus

Displaying Data from Multiple Tables

Subqueries Chapter 6

Aggregating Data Using Group Functions

RDBMS Using Oracle. Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture. kamran.munir@gmail.com. Joining Tables

Oracle/SQL Tutorial 1

Mini User's Guide for SQL*Plus T. J. Teorey

Oracle Database: SQL and PL/SQL Fundamentals

Oracle SQL. Course Summary. Duration. Objectives

Information and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query

SQL Introduction Chapter 7, sections 1 & 4. Introduction to SQL. Introduction to SQL. Introduction to SQL

Retrieval: Multiple Tables and Aggregation

Oracle Database 10g: Introduction to SQL

Hacking and Protecting Oracle DB. Slavik Markovich CTO, Sentrigo

Database CIS 340. lab#6. I.Arwa Najdi

Oracle Database: SQL and PL/SQL Fundamentals

SQL the natural language for analysis ORACLE WHITE PAPER JUNE 2015

Writing Control Structures

Using SQL Queries in Crystal Reports

Oracle Database 12c: Introduction to SQL Ed 1.1

Ad Hoc Advanced Table of Contents

Handling Exceptions. Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 8-1

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

Oracle Database: SQL and PL/SQL Fundamentals NEW

REPORT GENERATION USING SQL*PLUS COMMANDS

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

Data Models and Database Management Systems (DBMSs) Dr. Philip Cannata

SQL Server Database Coding Standards and Guidelines

D B M G Data Base and Data Mining Group of Politecnico di Torino

Database Programming with PL/SQL: Learning Objectives

Netezza SQL Class Outline

Recognizing PL/SQL Lexical Units. Copyright 2007, Oracle. All rights reserved.

Using TimesTen between your Application and Oracle. between your Application and Oracle. DOAG Conference 2011

White Paper. Blindfolded SQL Injection

1 Structured Query Language: Again. 2 Joining Tables

SQL Tuning Proven Methodologies

Oracle For Beginners Page : 1


Microsoft Access 3: Understanding and Creating Queries

Relational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )

Performing Queries Using PROC SQL (1)

Handling Exceptions. Schedule: Timing Topic. 45 minutes Lecture 20 minutes Practice 65 minutes Total

Advanced SQL. Jim Mason. Web solutions for iseries engineer, build, deploy, support, train

Introduction to the Oracle DBMS

Blindfolded SQL Injection. Written By: Ofer Maor Amichai Shulman

SQL and Data. Learning to Retrieve Data Efficiently and Accurately

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

ACCELL/SQL: Creating Reports with RPT Report Writer

Structured Query Language (SQL)

Introduction to Microsoft Jet SQL

Oracle Database: SQL and PL/SQL Fundamentals NEW

What's New in ADP Reporting?

Relational Database: Additional Operations on Relations; SQL

ERserver. DB2 Universal Database for iseries SQL Programming with Host Languages. iseries. Version 5

A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX

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

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

Advance DBMS. Structured Query Language (SQL)

GET DATA FROM MULTIPLE TABLES QUESTIONS

An Oracle White Paper August Express Mode Loading with SQL*Loader in Oracle Database 12c

ORACLE 10g Lab Guide

Resources You can find more resources for Sync & Save at our support site:

A basic create statement for a simple student table would look like the following.

Conversion Functions

SQL SELECT Query: Intermediate

ICAB4136B Use structured query language to create database structures and manipulate data

DB2 Developers Guide to Optimum SQL Performance

9.1 SAS. SQL Query Window. User s Guide

Chapter 2: Elements of Java

KB_SQL SQL Reference Guide Version 4

Appendix A Practices and Solutions

Handling Missing Values in the SQL Procedure

Financial Data Access with SQL, Excel & VBA

SQL interview questions and answers

Database Query 1: SQL Basics

UTILITIES BACKUP. Figure 25-1 Backup & Reindex utilities on the Main Menu

9 Using Triggers. Using Triggers 9-1

SIF Validation Tool. Wages Protection System Qatar Central Bank& Ministry of Labour And Social Affairs. End User Guide

Guide to Performance and Tuning: Query Performance and Sampled Selectivity

VARRAY AND NESTED TABLE

Qlik REST Connector Installation and User Guide

Differences in Use between Calc and Excel

SQL*Plus User s Guide and Reference

Oracle Database: Introduction to SQL

Data Mining Extensions (DMX) Reference

Objectives of SQL. Terminology for Relational Model. Introduction to SQL

PL / SQL Basics. Chapter 3

A Brief Introduction to MySQL

InterBase 6. Embedded SQL Guide. Borland/INPRISE. 100 Enterprise Way, Scotts Valley, CA

Tutorial 5 Creating Advanced Queries and Enhancing Table Design

Employment intermediaries: data requirements for software developers

Introduction to SQL: Data Retrieving

SQL Basics. Introduction to Standard Query Language

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Transcription:

THE SQL SELECT STATEMENT QUESTIONS http://www.tutorialspoint.com/sql_certificate/the_sql_select_statement_questions.htm Copyright tutorialspoint.com 1. Identify the capabilities of SELECT statement. A. Projection B. Selection C. Data Control D. Transaction Answer: A, B. The SELECT statement can be used for selection, projection and joining. 2. Determine the capability of the SELECT statement demonstrated in the given query. SELECT e.ename, d.dname WHERE e.deptno = d.deptno AND e.sal > 1000; A. Selection B. Filtering C. Joining D. Projection Answer: A, C, D. Projection is including only the required columns in query, while Selection is selecting only the required data. Joining means combining two tables together through a connecting column. 3. Which of the following clause is used to suppress duplicates in a SELECT statement? A. INTERSECT B. DUPLICATE C. DISTINCT D. UNIQUE Answer: C, D. Duplicate data can be restricted with the use of DISTINCT or UNIQUE in the SELECT statement. 4. Chose the statements which correctly specify a rule to write a SQL statement A. SQL statements are case sensitive B. Keywords can be abbreviated to build a standard C. SQL statements are case in-sensitive D. clauses must be placed together Answer: C.SQL statements are not case sensitive. 5. Determine the output of the below query - SELECT '5+7' FROM dual; A. 12 B. 5+7 C. 5

D. 7 Answer: B.Oracle treats the values within double quotes as string expressions. 6. Write a query to display employee details Name, Department, SalaryandJob from EMP table. SELECT ename, deptno, sal, job FROM emp; SELECT * FROM emp; SELECT DISTINCT ename, deptno, sal, job FROM emp; SELECT ename, deptno, sal FROM emp; Answer A.Select the required from the tables each separated by a comma. 7. Which of the below queries displays employees' name and new salary after the increment of 1000? SELECT ename, sal FROM emp; SELECT ename, sal=sal+1000 FROM emp; SELECT ename, sal+1000 FROM emp; SELECT ename, 1000 FROM emp; Answer: C. Basic arithmetic calculations can be done using the columns in SELECT statements. 8. Determine the output of the below query SELECT 36/2-5* 10 FROM dual; A. 130 B. -32 C. -120 D. 175 Answer: B. Multiplication and Division occur before addition and subtraction. 9. Determine the output of the below query SELECT (100-25)/15*(20-3) FROM dual; A. 0.294 B. -85 C. 63.67 D. 85 Answer: D. Expression within the brackets are executed before the divisions and multiplications in the expression. 10. Chose the statements which correctly define a NULL value. A. NULL is a special value with zero bytes B. NULL is no value or unknown value

C. NULL is represented by a blank space D. NULL is not same as zero Answer: B, D.NULL is NO VALUE but neither same as zero nor as blank or space character. 11. Determine the output of the below query SELECT sal + NULL FROM emp WHERE empno = 7369; A. sal + NULL B. NULL C. 0 D. 1250 Answer: B. Any arithmetic operation with NULL results in NULL. 12. Which of the below statements define column alias correctly? A. A column alias renames a column heading B. A column alias is an alternate column in a table C. A column alias can be specified during table definition D. A column alias immediately follows the column or expression in the SELECT statement Answer: A, D. Column Alias can be used to name an expression in the SELECT statement. 13. Specify the column alias NEWSAL for the expression containing salary in the below SQL query SELECT ename, job, sal + 100 FROM emp; A. sal + 100 AS NEWSAL B. sal + 100 NEWSAL C. sal + 100 IS NEWSAL D. sal + 100 IS NEWSAL Answer: A, B.Use 'AS' to signify new alias to a column expression. 14. Specify the column alias "New Salary" for the expression containing salary in the below SQL query SELECT ename, job, sal + 100 FROM emp; A. sal + 100 AS New Salary B. sal + 100 "New Salary" C. sal + 100 IS New Salary D. sal + 100 as "New Salary" Answer: B, D. Column alias with space and special characters must be enquoted within double quotes. 15. Which command is used to display the structure of a table? A. LIST B. SHOW

C. DESCRIBE D. STRUCTURE Answer: C.DESCRIBE is used to show the table structure. 16. Predict the output when below statement is executed in SQL* Plus? DESC emp A. Raises error "SP2-0042: unknown command "desc emp" - rest of line ignored." B. Lists the columns of EMP table C. Lists the EMP table columns, their data type and nullity D. Lists the columns of EMP table along with their data types Answer: C. DESCRIBE is used to show the table structure along with table columns, their data type and nullity 17. Which of the below statements are true about the DESCRIBE command? A. It can be used in SQL*Plus only B. It can be used in both SQL*Plus as well as SQL Developer C. It doesn't works for object tables D. It doesn't works for SYS owned tables Answer: B. 18. Which of the below alphanumeric characters are used to signify concatenation operator in SQL? A. + B. C. - D. :: Answer: B.In SQL, concatenation operator is represented by two vertical bars. 19. Which of the below statements are correct about the usage of concatenation operator in SQL? A. It creates a virtual column in the table B. It generates a character expression as the result of concatenation of one or more strings C. It creates a link between two character columns D. It can be used to concatenate date expressions with other columns Answer: B, D. Concatenation operator joins two values as an expression. 20. Predict the output of the below query SELECT ename NULL FROM emp WHERE empno = 7369 A. SMITH B. SMITH NULL C. SMITHNULL D. ORA-00904: "NULL": invalid identifier

Answer: A. Concatenation with NULL results into same value. 21. Predict the output of the below query SELECT 50 0001 FROM dual A. 500001 B. 51 C. 501 D. 5001 Answer: C. The leading zeroes in the right operand of expression are ignored by Oracle. 22. You execute the below query SELECT e.ename ' departments's name is:' d.dname where e.deptno=d.deptno; And get the exception - ORA-01756: quoted string not properly terminated. Which of the following solutions can permanently resolve the problem? A. Use double quote marks for the literal character string B. Use [q] operator to enquote the literal character string and selecting the delimiter of choice C. Remove the single quote mark apostrophe from the literal character string D. Use another delimiter to bypass the single quote apostrophe in the literal string Answer: B. The [q] operator is used to enquote character literals with a quote. 23. Which of the below SELECT statement shows the correct usage of [q] operator? SELECT e.ename q'[department's name is]' d.dname SELECT e.ename q['department's name is'] d.dname SELECT e.ename q[department's name is] d.dname SELECT e.ename q'(department's name is)' d.dname Answer: A 24. Which of the below SELECT statement is used to select all columns of EMP table? SELECT ALL FROM emp SELECT # FROM emp SELECT * FROM emp

SELECT empno,ename,deptno,sal,job,mgr,hiredate FROM emp Answer: C. The character '*' is used to select all the columns of the table. 25. Which of the below SQL query will display employee names, department, and annual salary? SELECT ename, deptno, sal FROM emp; SELECT ename, deptno, sal + comm FROM emp; SELECT ename, deptno, (sal * 12) Annual_Sal FROM emp; D. Annual salary cannot be queried since the column doesn't exists in the table Answer: C. Use numeric expressions in SELECT statement to perform basic arithmetic calculations. Loading [MathJax]/jax/output/HTML-CSS/jax.js