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
;
July 3, 2010 at 3:20 pm
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.
February 8, 2014 at 10:14 am
Вадим, огромное спасибо за отличную книгу!!!
С уважением, Михаил.
February 8, 2014 at 10:15 am
в ссылке на вторую главу есть маленькая опечатка (pdff вместо pdf)
…book_sql_chap2_v2.pdff
еще раз спасибо за книгу!!!!!!
February 10, 2014 at 8:13 pm
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.
February 11, 2014 at 3:43 am
I was not aware of UNION CORRESPONDING, thank you!
May 17, 2015 at 3:38 pm
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