typodupeerror
DEAL: For \$25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! ×

## JournalChacham's Journal: Verbiage: Solve AH + A = HEE in SQL10

Solve AH + A = HEE (where each letter is representative of a distinct number). Easy enough? Now do it in SQL. Yes, this post is insane, but short and elegant.

SELECT H.n||E.n||E.n as H_E_E
FROM
(SELECT LEVEL-1 n FROM DUAL CONNECT BY LEVEL <=10) A,
(SELECT LEVEL-1 n FROM DUAL CONNECT BY LEVEL <=10) H,
(SELECT LEVEL-1 n FROM DUAL CONNECT BY LEVEL <=10) E
WHERE A.n NOT IN (H.n, E.n)
AND H.n NOT IN (A.n, E.n)
AND E.n NOT IN (A.n, H.n)
AND mod(H.n + A.n - E.n, 10) = 0
AND mod(A.n + trunc((H.n + A.n - E.n)/10)- E.n, 10) = 0
AND trunc((A.n + trunc((H.n + A.n - E.n)/10) - E.n)/10) = H.n

This discussion has been archived. No new comments can be posted.

## Verbiage: Solve AH + A = HEE in SQL

• #### An Accountant's Answer (Score:2)

What would you like it to be?
• #### Re: (Score:1)

What would you like it to be?

There's a sign here that perhaps answers that question.

IIRC, part of it states something like:

This is the kitchen

IT is very unhygienic for everyone

So, to answer your question, i want IT to be hygienic for everyone.

• #### Doesn't work in postgresql (Score:2)

Either that, or I'm doing it wrong. I get the following error message:
ERROR: syntax error at or near "n" at character 52
LINE 3: (SELECT LEVEL-1 n FROM DUAL CONNECT BY LEVEL
• #### Re: (Score:1)

It may not like fake hierarchical queries. Perhaps SELECTing from a TABLE with ten records will do the job?

In Oracle, a similar construct would be SELECT Rownum -1 FROM User_Objects WHERE Rownum 11;
• #### Meta-stupid question (Score:2)

Uhhh...isn't CONNECT BY an Oracle-specific extension to Stupid Question Language?
• #### If you say so (Score:2)

I know nothing about CONNECT BY nor Oracle, so it makes sense...
That was one reason I tried his statement, because I thought I'd learn something from it. I suppose I have!
• #### Re: (Score:1)

isn't CONNECT BY an Oracle-specific extension

Yes. In ANSI a recursive WITH could be used.

to Stupid Question Language?

Not sure why you are mocking Oracle on this. After all,Relational Software, Inc. (now Oracle Corporartion) was the first commercial implementation of SQL (1979) well before there was a standard.
• #### Re: (Score:2)

Wasn't mocking Oracle at all. I refer to SQL as "Squeal" or "Stupid Question Language" in conversation.
Truly, I respect the functional style of programming embodied thereby, even though most of the work I do involves Microsoft Abcess.
• #### Re: (Score:1)

Ah, OK then.

I seem to be taking everything the wrong way today. :)
• #### Re: (Score:2)

I will pause for a moment to admire the commitment to minimalism embodied in http://tkatch.com/ [tkatch.com]

Real Users find the one combination of bizarre input values that shuts down the system for days.

Working...