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
The SQL ‘CREATE TABLE' scripts for all the tables you have implemented. Note that your tables must correspond exactly to the ERD you have provided in 1. above, or you will lose ma

When Are Constraints Checked Under the model constraints are conceptually checked at all statement boundaries (and only at statement boundaries). By default the same is true

What are the rates for help in writing PL/SQL procedures and functions?

Updating by insertion Syntax : INSERT INTO ENROLMENT VALUES (SID ('S4'), 'Devinder', CID ('C1'));

Package STANDARD The package named STANDARD defines the PL/SQL atmosphere. The package specification globally declares the exceptions, types, and subprograms that are available

Cursors   To execute the multi-row query, the Oracle opens an unnamed work region which stores the processing information. The cursor names the work region, access the informa

Many of the reports generated from the system calculate the total dollars in a shopper''s purchases. Follow these steps to create a function named TOT_PURCH_SF that accepts a shopp

SQLs counterpart of the key words: The text from the opening parenthesis to the end of the fourth line specifies the declared type of the table, meaning that every table ever

Anatomy of a Table: Figure shows the terminology used in SQL to refer to parts of the structure of a table. As you can see, SQL has no official terms for its counterpa

Perform the following queries on the Hospital1.DB using SQL Anywhere (START EARLY!). a. Which patients have purchased the drug "Tylenol"? List the names and addresses. Arrange the