Re: SUM problem.
Actually,
I solved your problem the first time and tested it and it worked. You only had to put in the right column and table names.
What you did was far more complex than an accurate single SQL query solution is and is called "hacking" - something that used to be frowned upon 20 or so years back, but seems to be all the rage today.
Ergo:
#1 if something seems too complex to you, it's probably the case that further reading and self-education are called for
#2 temporary tables are only needed in cases such as a data model that won't support a direct query or can't do so efficiently, the need to create multiple different results sets for reference (e.g. summary aggregate tables in a data warehouse) from the same intermediate result such that the temporary table is re-used, the optimizer can't handle the query (Postgres comes to mind primarily in this scenario)
#4 "Simple" in SQL doesn't mean "top down iterative" - you prefer an iterative solution because that is how your mind is able to grasp the problem more easily - SQL is *iterative* in nature, but the language does not *look* iterative. The solution I gave you was highly iterative in nature, but it executed from the inside out rather than top down - that's the big difference with SQL - if you are to master it some day, you must learn to understand programming semantics that are not top down. For a different language that requires a similar way of thinking, look into the Lisp programming language. Learn to write Lisp and you'll have a far easier time understand SQL. The reverse is not necessarily true.
Ah well, just the same, it's good you read some stuff and solved the problem a different way on your own. Your result is *a* solution, more complex and harder to maintain, but a solution nonetheless and that oftentimes is all that matters to many folks these days ... alas.
--chris
Subject
Written By
Posted
Re: SUM problem.
March 22, 2009 05:01PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.