Skip to content

Commit

Permalink
Sample Files
Browse files Browse the repository at this point in the history
  • Loading branch information
DJSteele committed Jul 30, 2016
1 parent d90d0db commit ecaef2c
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 66 deletions.
4 changes: 2 additions & 2 deletions IBM DB2/Chapter 05/Listing 5.004.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
SET SCHEMA Item30Example;

-- Listing 5.4 ROLLUP sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY ROLLUP (Color, Size);
GROUP BY ROLLUP (Color, Dimension);
4 changes: 2 additions & 2 deletions IBM DB2/Chapter 05/Listing 5.005.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SET SCHEMA Item30Example;

-- Listing 5.5 CUBE sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY CUBE (Color, Size);
GROUP BY CUBE (Color, Dimension);

4 changes: 2 additions & 2 deletions IBM DB2/Chapter 05/Listing 5.006.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SET SCHEMA Item30Example;

-- Listing 5.6 GROUPING SETS sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY GROUPING SETS ((Color), (Size), ());
GROUP BY GROUPING SETS ((Color), (Dimension), ());

6 changes: 3 additions & 3 deletions IBM DB2/Chapter 05/Listing 5.007.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
SET SCHEMA Item30Example;

-- Listing 5.7 Using simple GROUP BY instead of GROUPING SETS
SELECT Color, NULL AS Size, SUM(Quantity) AS TotalQuantity
SELECT Color, NULL AS Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY Color
UNION
SELECT NULL, Size, SUM(Quantity)
SELECT NULL, Dimension, SUM(Quantity)
FROM Inventory
GROUP BY Size
GROUP BY Dimension
UNION
SELECT NULL, NULL, SUM(Quantity)
FROM Inventory;
10 changes: 5 additions & 5 deletions IBM DB2/Sample Databases/Item30StructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ SET SCHEMA Item30Example;

CREATE TABLE Inventory (
Color varchar(15) NULL,
Size varchar(5) NULL,
Dimension varchar(5) NULL,
Quantity int NULL
);

INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'L', 5);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'L', 5);
4 changes: 2 additions & 2 deletions Microsoft SQL Server/Chapter 05/Listing 5.004.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ USE Item30Example;
GO

-- Listing 5.4 ROLLUP sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY ROLLUP (Color, Size);
GROUP BY ROLLUP (Color, Dimension);
4 changes: 2 additions & 2 deletions Microsoft SQL Server/Chapter 05/Listing 5.005.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USE Item30Example;
GO

-- Listing 5.5 CUBE sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY CUBE (Color, Size);
GROUP BY CUBE (Color, Dimension);

4 changes: 2 additions & 2 deletions Microsoft SQL Server/Chapter 05/Listing 5.006.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GO


-- Listing 5.6 GROUPING SETS sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY GROUPING SETS ((Color), (Size), ());
GROUP BY GROUPING SETS ((Color), (Dimension), ());

6 changes: 3 additions & 3 deletions Microsoft SQL Server/Chapter 05/Listing 5.007.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ USE Item30Example;
GO

-- Listing 5.7 Using simple GROUP BY instead of GROUPING SETS
SELECT Color, NULL AS Size, SUM(Quantity) AS TotalQuantity
SELECT Color, NULL AS Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY Color
UNION
SELECT NULL, Size, SUM(Quantity)
SELECT NULL, Dimension, SUM(Quantity)
FROM Inventory
GROUP BY Size
GROUP BY Dimension
UNION
SELECT NULL, NULL, SUM(Quantity)
FROM Inventory;
10 changes: 5 additions & 5 deletions Microsoft SQL Server/Sample Databases/Item30StructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ USE Item30Example;

CREATE TABLE Inventory (
Color varchar(15) NULL,
Size varchar(5) NULL,
Dimension varchar(5) NULL,
Quantity int NULL
);
GO

INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'L', 5);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'L', 5);

GO
4 changes: 2 additions & 2 deletions MySQL/Chapter 05/Listing 5.004.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
USE Item30Example;

-- Listing 5.4 ROLLUP sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY Color, Size WITH ROLLUP;
GROUP BY Color, Dimension WITH ROLLUP;
6 changes: 3 additions & 3 deletions MySQL/Chapter 05/Listing 5.007.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
USE Item30Example;

-- Listing 5.7 Using simple GROUP BY instead of GROUPING SETS
SELECT Color, NULL AS Size, SUM(Quantity) AS TotalQuantity
SELECT Color, NULL AS Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY Color
UNION
SELECT NULL, Size, SUM(Quantity)
SELECT NULL, Dimension, SUM(Quantity)
FROM Inventory
GROUP BY Size
GROUP BY Dimension
UNION
SELECT NULL, NULL, SUM(Quantity)
FROM Inventory;
10 changes: 5 additions & 5 deletions MySQL/Sample Databases/Item30StructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ USE Item30Example;

CREATE TABLE Inventory (
Color varchar(15) NULL,
Size varchar(5) NULL,
Dimension varchar(5) NULL,
Quantity int NULL
);

INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'L', 5);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'L', 5);

4 changes: 2 additions & 2 deletions Oracle/Chapter 05/Listing 5.004.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
ALTER SESSION SET CURRENT_SCHEMA = Item30Example;

-- Listing 5.4 ROLLUP sample query
SELECT Color, "Size", SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY ROLLUP (Color, "Size");
GROUP BY ROLLUP (Color, Dimension);
4 changes: 2 additions & 2 deletions Oracle/Chapter 05/Listing 5.005.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ALTER SESSION SET CURRENT_SCHEMA = Item30Example;

-- Listing 5.5 CUBE sample query
SELECT Color, "Size", SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY CUBE (Color, "Size");
GROUP BY CUBE (Color, Dimension);

4 changes: 2 additions & 2 deletions Oracle/Chapter 05/Listing 5.006.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ALTER SESSION SET CURRENT_SCHEMA = Item30Example;

-- Listing 5.6 GROUPING SETS sample query
SELECT Color, "Size", SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY GROUPING SETS ((Color), ("Size"), ());
GROUP BY GROUPING SETS ((Color), (Dimension), ());

6 changes: 3 additions & 3 deletions Oracle/Chapter 05/Listing 5.007.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
ALTER SESSION SET CURRENT_SCHEMA = Item30Example;

-- Listing 5.7 Using simple GROUP BY instead of GROUPING SETS
SELECT Color, NULL AS "Size", SUM(Quantity) AS TotalQuantity
SELECT Color, NULL AS Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY Color
UNION
SELECT NULL, "Size", SUM(Quantity)
SELECT NULL, Dimension, SUM(Quantity)
FROM Inventory
GROUP BY "Size"
GROUP BY Dimension
UNION
SELECT NULL, NULL, SUM(Quantity)
FROM Inventory;
10 changes: 5 additions & 5 deletions Oracle/Sample Databases/Item30StructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ ALTER SESSION SET CURRENT_SCHEMA = ITEM30EXAMPLE;

CREATE TABLE Inventory (
Color varchar(15) NULL,
"Size" varchar(5) NULL,
Dimension varchar(5) NULL,
Quantity int NULL
);

INSERT INTO Inventory (Color, "Size", Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, "Size", Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, "Size", Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, "Size", Quantity) VALUES ('Blue', 'L', 5);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'L', 5);
4 changes: 2 additions & 2 deletions PostgreSQL/Chapter 05/Listing 5.004.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
SET search_path = Item30Example;

-- Listing 5.4 ROLLUP sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY ROLLUP (Color, Size);
GROUP BY ROLLUP (Color, Dimension);
4 changes: 2 additions & 2 deletions PostgreSQL/Chapter 05/Listing 5.005.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SET search_path = Item30Example;

-- Listing 5.5 CUBE sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY CUBE (Color, Size);
GROUP BY CUBE (Color, Dimension);

4 changes: 2 additions & 2 deletions PostgreSQL/Chapter 05/Listing 5.006.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SET search_path = Item30Example;

-- Listing 5.6 GROUPING SETS sample query
SELECT Color, Size, SUM(Quantity) AS TotalQuantity
SELECT Color, Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY GROUPING SETS ((Color), (Size), ());
GROUP BY GROUPING SETS ((Color), (Dimension), ());

6 changes: 3 additions & 3 deletions PostgreSQL/Chapter 05/Listing 5.007.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
SET search_path = Item30Example;

-- Listing 5.7 Using simple GROUP BY instead of GROUPING SETS
SELECT Color, NULL AS Size, SUM(Quantity) AS TotalQuantity
SELECT Color, NULL AS Dimension, SUM(Quantity) AS TotalQuantity
FROM Inventory
GROUP BY Color
UNION
SELECT NULL, Size, SUM(Quantity)
SELECT NULL, Dimension, SUM(Quantity)
FROM Inventory
GROUP BY Size
GROUP BY Dimension
UNION
SELECT NULL, NULL, SUM(Quantity)
FROM Inventory;
10 changes: 5 additions & 5 deletions PostgreSQL/Sample Databases/Item30StructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ SET search_path TO Item30Example;

CREATE TABLE Inventory (
Color varchar(15) NULL,
Size varchar(5) NULL,
Dimension varchar(5) NULL,
Quantity int NULL
);

INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Size, Quantity) VALUES ('Blue', 'L', 5);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'L', 10);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'M', 20);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Red', 'M', 15);
INSERT INTO Inventory (Color, Dimension, Quantity) VALUES ('Blue', 'L', 5);

0 comments on commit ecaef2c

Please sign in to comment.