| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: 3 value logic. Why is SQL so special?
Roy Hann wrote:
> No doubt--because you are doing at run-time what could have been done at
> design time. How is your life made simpler by ISNULL?
For example, in the duplicate-checking process I mentioned earlier, there might be some code such as:
SELECT FirstName,
LastName,
ISNULL(MiddleName, '') AS MiddleName,
COUNT(*) AS Cnt
FirstName,
LastName,
ISNULL(MiddleName, '')
HAVING
COUNT(*) > 1
This single query covers both customers with and without a MiddleName. If I had a separate CustomerMiddleName table, I would need to do a UNION to achieve the same thing (or a LEFT OUTER JOIN, but apparently these are bad too - what is your opinion on this?):
SELECT C.FirstName,
C.LastName,
'' AS MiddleName,
COUNT(*) AS Cnt
NOT EXISTS(SELECT *
FROM CustomerMiddleName CM
WHERE CM.CustomerID = C.CustomerID)
GROUP BY
C.FirstName,
C.LastName
UNION SELECT C.FirstName,
C.LastName,
CM.MiddleName,
COUNT(*) AS Cnt
ON CM.CustomerID = C.CustomerID
GROUP BY
FirstName,
LastName,
MiddleName
HAVING
COUNT(*) > 1
> The compexity doesn't go away. Any additional tables merely reveal the
> complexity that is otherwise hidden, lying in wait but still very much
> there. If you don't resolve it with a complex query you have to resolve it
> with complex code somewhere else. As horrid as it is, SQL is still almost
Isn't it better to hide complexity then, assuming that you end up with the correct result? Like you say, self-discipline keeps us out of trouble.
Chris Received on Tue Sep 19 2006 - 04:00:58 CDT
![]() |
![]() |