I disagree that Relational Division comes once in a lifetime. I use it all the time for reports that look for “shopping basket” patterns in sales data.
Hi Vadim, a thread on another forum has mentioned an exotic operator you don’t include:
SQL’s UNION CORRESPONDING seems to be the same as the RL’s inner union.
(Hugh Darwen says that this operator was available in ISBL/BS12, called plain UNION. So not the same as SQL’s plain UNION.)
I don’t see any evidence that anybody realised this operation is the inverse of Nat Join.
and replaced their query versions of your example queries on their database. It worked a treat. But my version of the scalar subquery
SELECT t.ContactName t, t.CustomerID id,
(SELECT count(*) from Customers tt WHERE tt.CustomerID < t.CustomerId) seq
FROM Customers t
GROUP BY t.CustomerID
;
is not exactly the same query as you gave – no #, and <= is replaced with <
But it also return zero as a result which did not occur in my version of the predecessor query
SELECT t.ContactName t, t.CustomerID id, Max(tt.CustomerID) predecessor FROM Customers t, Customers tt WHERE tt.CustomerID < t.CustomerID
GROUP BY t.CustomerID
;
I disagree that Relational Division comes once in a lifetime. I use it all the time for reports that look for “shopping basket” patterns in sales data.
Вадим, огромное спасибо за отличную книгу!!!
С уважением, Михаил.
в ссылке на вторую главу есть маленькая опечатка (pdff вместо pdf)
…book_sql_chap2_v2.pdff
еще раз спасибо за книгу!!!!!!
Hi Vadim, a thread on another forum has mentioned an exotic operator you don’t include:
SQL’s UNION CORRESPONDING seems to be the same as the RL’s inner union.
(Hugh Darwen says that this operator was available in ISBL/BS12, called plain UNION. So not the same as SQL’s plain UNION.)
I don’t see any evidence that anybody realised this operation is the inverse of Nat Join.
I was not aware of UNION CORRESPONDING, thank you!
Hi Vadim
Just bought your book and reading chapter 1 counting. I have a minor quibble about the scalar subquery corresponding to the predecessor example
I ran your examples on the northwind sample database using the web interface on w3 schools http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
and replaced their query versions of your example queries on their database. It worked a treat. But my version of the scalar subquery
SELECT t.ContactName t, t.CustomerID id,
(SELECT count(*) from Customers tt WHERE tt.CustomerID < t.CustomerId) seq
FROM Customers t
GROUP BY t.CustomerID
;
is not exactly the same query as you gave – no #, and <= is replaced with <
But it also return zero as a result which did not occur in my version of the predecessor query
SELECT t.ContactName t, t.CustomerID id, Max(tt.CustomerID) predecessor FROM Customers t, Customers tt WHERE tt.CustomerID < t.CustomerID
GROUP BY t.CustomerID
;
thanks
Dave