Oracle FAQ
|
Your Portal to the Oracle Knowledge Grid
|
Home ->
Community ->
Usenet ->
c.d.o.misc ->
Re: Not very good at SQL, trying to query multiple tables
Re: Not very good at SQL, trying to query multiple tables
Just a couple of comments;
1. Always bottom post in this group
2. The to_date function should be on the date literal in the where
clause because;
- you would need a to_char function to compare with a character
string, but even better
- put the to_date function on the literal so that if there is an index
on the column, it can be used
ex: " and RE.begtime between to_date('2006-07-01','YYYY-MM-DD')
and to_date('2006-07-31','YYYY-MM-DD')
(or is the RE.begtime not a date type column? - if so, simply change
the literal...)
3. You hinted at the table primary and foreign keys with the business
logic, but I find that when you combine several tables together, one of
the trickiest part is to always ensure that every row combination is
properly restricted - to avoid a multiplication factor. You can add a
"count(*)" in the select column list to see if the the generated number
of rows is in the ballpark of what you would expect. The group by
clause will sometime hide such an error, and the only way you would
find out is if the sum(ro.rollwidth) was some unrealistic number.
extra 2 cents
Received on Tue Aug 01 2006 - 11:54:16 CDT
Original text of this message