Using rename in combination with join - sql, PL-SQL Programming

Assignment Help:

Using RENAME in combination with JOIN - SQL

Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent expression in SQL.

Example: Renaming and joining

Student Sid1 is called Name and so is student Sid2

SELECT *

FROM   (SELECT StudentId AS Sid1, Name FROM IS_CALLED)

     NATURAL JOIN

     (SELECT StudentId AS Sid2, Name FROM IS_CALLED)

As before, the result sagely tells us that student S1 (Anne) has the same name as herself and also shows two pairings of S1 with S5 (both named Boris). The pairing of a student id with itself can be avoided by adding WHERE Sid1 < > Sid2 to the WHERE clause. The duplicate pairings can further be avoided by using < instead of < > in this addition, but that trick assumes that an ordering is defined for type SID, which is not necessarily the case.


Related Discussions:- Using rename in combination with join - sql

Example of alternative formulation as a table constraint, Example of Altern...

Example of Alternative formulation as a table constraint Example: Alternative formulation as a table constraint ALTER TABLE EXAM_MARK ADD CONSTRAINT Must_be_enrolled_to_

Oracle 10g new features and differences , Oracle 10G new features:- Au...

Oracle 10G new features:- Automatic Database Diagnostic Monitor System Advancements - these methods will provides several methods for extracting reports through the Automatic

Calculating a Shopper''s Total Spending, Many of the reports generated from...

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

Committing and rolling back - autonomous transaction, Committing and Rollin...

Committing and Rolling Back The COMMIT and ROLLBACK end the active autonomous transaction but do not exit the autonomous routine. As the figure shows, if one transaction ends,

Bulk fetching - bulk bind performance improvement, Bulk Fetching The i...

Bulk Fetching The illustration below shows that you can bulk-fetch from a cursor into one or more collections: DECLARE TYPE NameTab IS TABLE OF emp.ename%TYPE; TYPE S

Case sensitivity-naming conventions, Case Sensitivity Similar to all the...

Case Sensitivity Similar to all the identifiers, the variables, the names of constants, and parameters are not case sensitive. For illustration, PL/SQL considers the following n

Translate the given er schema into sql, Consider the schema for FreeCheckin...

Consider the schema for FreeChecking Bank, that we designed given below. Translate the given ER schema into SQL CREATE TABLE statements (indicating primary key, unique and foreign

For-loop -iterative control, FOR-LOOP While the number of iterations thr...

FOR-LOOP While the number of iterations through a WHILE loop is unknown till the loop completes, then the number of iterations through a FOR loop is known before the loop is ent

Ssrs report writing, SSRS Report Writing Project Description: This re...

SSRS Report Writing Project Description: This report is part of a larger project to make a SQL Server Reporting Service (SSRS) based reporting solution. There can be more rep

Effects of null, Effects of NULL The numeric variable X, perhaps of ty...

Effects of NULL The numeric variable X, perhaps of type INTEGER, might be assigned NULL. In that case the result of evaluating X + 1 is NULL, and so SET Y = X + 1 assigns NULL

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd