![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
-- returns no rows! WHY? select o.form_id, o.date_logged, o.date_logged as fubar, min(r.date_replied) as date_replied_r, min(r.date_logged) as date_logged_r from k2_mailing o join form_reminder f on f.original_form=o.form_id join k2_mailing r on r.form_id=f.form_id group by 1,2,3; \p\g |
#3
| |||
| |||
|
|
-- returns no rows! WHY? select o.form_id, o.date_logged, o.date_logged as fubar, min(r.date_replied) as date_replied_r, min(r.date_logged) as date_logged_r from k2_mailing o join form_reminder f on f.original_form=o.form_id join k2_mailing r on r.form_id=f.form_id group by 1,2,3; \p\g |
#4
| |||
| |||
|
|
I've just been shown the following usage of min() and its results have got me puzzled. |
#5
| |||
| |||
|
|
I've just been shown the following usage of min() and its results have got me puzzled. Why id you write so much needless dialect? Tables with all NULL-able columns. No keys? No ISO-8601 DATE as required by Standards? Then why did you do a GROUP BY with ordinal position numbers??!! |
#6
| |||
| |||
|
|
SELECT O.form_id, O.log_date, -- why have the same column twice? Does 1NF mean anything?? MIN (R.reply_date) AS min_reply_date, MIN (R.log_date) AS min_log_date FROM K2_Mailings AS O, Form_Reminders AS F, K2_Mailings AS R WHERE R.form_id = F.form_id AND F.original_form = O.form_id GROUP BY O.form_id, O.log_date; -- no stinking ordinals in RDBMS!, |
|
from k2_mailing o join form_reminder f on f.original_form=o.form_id join k2_mailing r on r.form_id=f.form_id |
|
The SELECT is done last so alias names are not known to the GROUP BY in real SQL. |
#7
| |||
| |||
|
|
I've just been shown the following usage of min() and its results have got me puzzled. Why id you write so much needless dialect? Tables with all NULL-able columns. No keys? No ISO-8601 DATE as required by Standards? Then why did you do a GROUP BY with ordinal position numbers??!! Did your auditor really let you put logging dates in the table being audited!!?? |
#8
| ||||||
| ||||||
|
|
Why id you write so much needless dialect? I didn't, it was shown to me by the programmers. They are somewhat |
|
Tables with all NULL-able columns. No keys? That was my trivial example of the problem as much as anything else. I |
|
No ISO-8601 DATE as required by Standards? We just use ingresdate, it seems OK for what we need. |
|
Then why did you do a GROUP BY with ordinal position numbers??!! Slackness. I tell the programmers to use column names, but its their |
|
Did your auditor really let you put logging dates in the table being audited!!?? That's the way, uh-huh, uh-huh, they like it. |
|
Most of your posting should have failed and given an error message rather than just no rows. This is all wrong!! Granted, but the query *MUST* return the correct data. If ingres got all |
#9
| |||
| |||
|
|
If Marty wrote that stuff himself ab initio, I trust that he has enough sense to keep quiet about it. :-) I'm not that smart! |
|
I applaud all of it, but at the same time, Ingres is supposed to give the right friggin answer no matter how disturbed, evil, wrong, and broken the query is... Damn right! |
#10
| |||
| |||
|
|
That took me awhile to understand. *You mean that tuples are formed, logically, as a Cartesian product of the tables, the WHERE clause filters them, the GROUP BY consolidates them, and the SELECT statement chooses columns. *And because things are -- theoretically -- done thus, the GROUP BY can't know the aliases established "later" by SELECT. *Except, who appliesthe aggregation functions? *Doesn't GROUP BY have to peek? * |
![]() |
| Thread Tools | |
| Display Modes | |
| |