Difference between revisions of "Import data"

From SQLZOO
Jump to: navigation, search
(Created page with "Import someone else's data. <div class='ht'> <div class=params>schema:scott</div> <source lang=sql class='tidy'>DROP TABLE employeeParking; DROP TABLE employeeCopy;</source> <...")
 
Line 21: Line 21:
 
</div>
 
</div>
  
<source lang='sql' class='def'>CREATE VIEW mimic AS
+
<source lang='sql' class='def'>CREATE VIEW testCopy AS
 
SELECT employeeParking.id, COALESCE(name, employeeParking.id) AS name,
 
SELECT employeeParking.id, COALESCE(name, employeeParking.id) AS name,
 
COALESCE(phone, 'Not Available') AS phone, parkingSpace
 
COALESCE(phone, 'Not Available') AS phone, parkingSpace

Revision as of 09:47, 31 July 2012

Import someone else's data.

schema:scott
DROP TABLE employeeParking;
DROP TABLE employeeCopy;
 CREATE TABLE employeeParking(
  id TEXT,
  parkingSpace TEXT );
INSERT INTO employeeParking VALUES ('E01','F8');
INSERT INTO employeeParking VALUES ('E02','G22');
INSERT INTO employeeParking VALUES ('E03','F7');
CREATE TABLE employeeCopy (
  id TEXT,
  name VARCHAR(20),
  phone INTEGER );
INSERT INTO employeeCopy VALUES ('E01','Harpo',2753);
INSERT INTO employeeCopy VALUES ('E02','Zeppo',2754);
INSERT INTO employeeCopy VALUES ('E03','Groucho',2755);
CREATE VIEW testCopy AS
SELECT employeeParking.id, COALESCE(name, employeeParking.id) AS name,
COALESCE(phone, 'Not Available') AS phone, parkingSpace
FROM employeeParking LEFT OUTER JOIN
employeeCopy ON (employeeParking.id = employeeCopy.id)
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense