Example of coalesce operator - sql, PL-SQL Programming

Example of COALESCE operator

Example: Give the total of marks for each exam (simplified solution)

SELECT CourseId,

COALESCE ((SELECT SUM (Mark)

FROM EXAM_MARK AS EM

WHERE EM.CourseId = C.CourseId ),

 0) AS TotalMark

FROM COURSE AS C

Explanation

  • The first operand to the invocation of COALESCE is a scalar subquery similar to Aggregate Operators. Recall the need to enclose the SELECT expression in parentheses, without which it would denote a table rather than a number.
Posted Date: 1/18/2013 6:38:57 AM | Location : United States







Related Discussions:- Example of coalesce operator - sql, Assignment Help, Ask Question on Example of coalesce operator - sql, Get Answer, Expert's Help, Example of coalesce operator - sql Discussions

Write discussion on Example of coalesce operator - sql
Your posts are moderated
Related Questions
Logical Connectives - SQL SQL's extended truth tables in which the symbol, for unknown, appears along with the usual T and F. Negation (NOT, ¬) Conjunction (

Effects of NULL in Table Literal When a VALUES expression appears as the source value for an SQL INSERT statement, the key word NULL can appear as a field value, such that for

Type versus Representation Confusion in SQL This describes how a value might have two or more distinct representations. For example, user-defined type POINT might have a decla

Updating Variables For assignment, SQL uses the key word SET, as in SET X = X + 1 (read as "set X equal to X+1") rather than X: = X + 1 as found in many computer languages.

Stored Subprograms Normally, tools (like Oracle Forms) which incorporate the PL/SQL engine can store subprograms locally for later, strictly local execution. Though, to become

Package Specification The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to the

Deleting Objects You can use the DELETE statement to eradicate objects from an object table. To eradicate objects selectively, you use the WHERE clause, as shown below: BEG

Object Type: The object type is a user-defined composite datatype which encapsulates a data structure along with the functions and procedures required to manipulate the data

Example of Shorthand for a row constraint Example: Shorthand for a row constraint ALTER TABLE EXAM_MARK ADD CONSTRAINT Mark_in_range CHECK (Mark BETWEEN 0 AND 100);

What Is a Collection The collection is an ordered group of elements, all of similar type (for e.g. the grades for a class of students). Each element has a unique subscript whic