You are on page 1of 4

2/11/13

oracle SUB QUERY IN SELECT CLAUSE


Search

Sub Query In Select Clause


Oracle SQL Course Home
Oracle SQL

Sub-Query in SELECT clause is nothing but providing SELECT statement in the place of column name. Sub query in SELECT should always return one value. It can be Independent query or it can be dependent by joining with one of table/view in from clause.

Chapter 1: Introduction
What is a Database? What is DBMS? What is RDBMS? What is SQL? RDBMS Products In The Market

Example1:SLSLC epo Q>EET mn, eae nm, sl a, (EETMX(a)FO ep SLC A sl RM m) mxa FO ep asl RM m;

Chapter 2: Basics of Oracle SQL


Users and Schemas Introduction to Data Modeling Introduction to Data Dictionary Oracle SQL Data Types

Chapter 3: DDL
C reate Table SQL Alter Table Truncate Table Drop Table Rename Table

Chapter 4: DML
Insert C ommand Update C ommand Delete C ommand Merge C ommand

In the above example we have provided SELECT STATEMENT in the place of column name which will return only single value. If we try to return multiple values, system will raise an error which is shown below.

Chapter 5: Constraints
What are C onstraints? Not Null C onstraint C heck C onstraint Unique C onstraint Primary Key C onstraint Foreign Key C onstraint ON Delete C ascade C omposite Keys

SLSLC epo Q>EET mn, eae nm, sl a, (EETMX(a)FO ep GOPB dpn) SLC A sl RM m RU Y eto mxa FO ep asl RM m;
Output:ORA-01427: single-row sub query returns more than one row. In the above SELECT STATEMENT use of GROUP BY returns multiple values.

Chapter 6: TCL
Oracle SQL C ommit Rollback Savepoint

Example2:In this example we are trying to fetch highest and lowest salary for each department.

Chapter 7: DCL
Grant Revoke

Chapter 8: DRL & Clauses


SELEC T Where C lause ORDER BY GROUP BY Having C lause

SLSLC epo Q>EET mn, eae nm, sl a, dpn, eto (EETmn(a)FO epWEEdpn=.etolsl SLC i sl RM m HR etoedpn)oa, (EETmx(a)FO epWEEdpn=.eto hsl SLC a sl RM m HR etoedpn) ia FO EPeODRB dpn; RM M RE Y eto

Chapter 9: Operators
SQL Operators SQL Types of Operators IN & NOT IN

newtonapples.com/or16-51-sub-query-in-select-clause/

1/4

2/11/13
BETWEEN, NOT BETWEEN LIKE, NOT LIKE IS NULL, IS NOT NULL C oncatenation ( || ) Operator

oracle SUB QUERY IN SELECT CLAUSE

Chapter 10: Relational Operators


Equals to (=) Operator Less than (<) Operator Greater than (>) Operator Less than or Equals to (<=) Operator Greater than or Equals to (>=) Operator Not Equals to ( != / ^= / <> ) Operator SQL IN Operator SQL BETWEEN Operator SQL LIKE Operator SQL IS NULL Operator SQL C oncatenation ( || ) Operator

<< Sub Query In From Clause

Sub Query In Where Clause>>

This post has been viewed 104 times

Chapter 11: Relational Negation Operators


SQL NOT LIKE Operator SQL Not Equals to ( != / ^= / <> ) Operator SQL NOT IN Operator SQL NOT BETWEEN Operator SQL IS NOT NULL Operator

Chapter 12: Logical Operators


Logical AND Operator Logical OR Operator Logical NOT Operator

Chapter 13: Arithmetic Operators


Multiplication (*) Operator Division ( / ) Operator Addition (+) Operator in SQL Subtraction (-) Operator

Chapter 14: Functions


String Functions Numeric Functions Date Functions C onversion Functions Group Functions

Chapter 15: Joins


What Is a Join? Inner Join (or) Simple Join (or) Equi Join Left Outer Join Right Outer Join Full Outer Join C ross Join Non-Equi Join

Chapter 16: Subqueries


Sub Query Sub Query In From C lause Sub Query In Select Clause Sub Query In Where C lause Nested Sub Queries

Chapter 17: Set Operators

newtonapples.com/or16-51-sub-query-in-select-clause/

2/4

2/11/13
UNION UNION ALL INTERSEC T MINUS

oracle SUB QUERY IN SELECT CLAUSE

Chapter 18: Indexes


Index Unique Index Non Unique Indexes C omposite Index Function Based Index

Chapter 19: Synonym


Synonym Private Synonym Public Synonym

Chapter 20: Sequence


What Is Sequence? Using A Sequence Altering And Dropping The Sequence

Chapter 21: Views


View Simple View C omplex Views DML Operations on Views MATERIALIZED VIEW Difference Between Normal and Materialized View Force View

Video Tutorials Expert Atricles Tips and Code Assignments & Quizzes Corner Interview Questions

.. See other relevant topics Oracle PL/SQL Oracle Financials Oracle DBA Oracle Forms and Reports Oracle Apps

About the Author: Venkat (3 votes, average: 5.00 out of 5)


Disclaimer: Contents expressed in this post are viewpoints of independent authors/contributors and are not reviewed for correctness or accuracy by NewtonApples.com. Any opinions, comments, solutions or other commentary expressed by post authors/contributors are not endorsed or recommended by NewtonApples.com or any vendor. If you feel a post is inappropriate, click here to let us know and we will take the appropriate action

Comments Closed
Testimonials
I've been a member since they started and I'm proud to tell you all that I have grow to the level of being a faculty at Newton Apples - Anusha

Tag Cloud
basics bill inmon bottom up c

Most Viewed
Notable new Features in DataStage 8.5 DS|02|-06. Stages in DataStage Unix Scripts to run DataStage jobs

language clause constraint c


tutorial c tutorials Cursors
DataStage DataStage 8.5
DataStage 8.7 Data Warehousing

newtonapples.com/or16-51-sub-query-in-select-clause/

3/4

2/11/13

oracle SUB QUERY IN SELECT CLAUSE


dimension ER diagram exceptions fact

Functions IBM index Joins new in


DataStage

oaf operator

DS|01|-02. DataStage Architecture & Client Components DS|01|-04. Parallel Processing & Partition Techniques DataStage Job Status Automation DS|00|-01. IBM InfoSphere DataStage

operators

Oracle

oracleapps oracleplsql
Oracle SQL package PLSQL
sequence

QualityStage ralph kimball schema

snowflake

sqlfunctions sql functions start Subqueries top down Triggers views

Sql

xmlpublisher
Newton Apples Copying, replication, and distribution of content available on NewtonApples.com is prohibited

newtonapples.com/or16-51-sub-query-in-select-clause/

4/4

You might also like