A temporary table is a place to store relevant to your needs. Whether you are an application or some end-user. It is a place to keep data. It helps give SQL coding options. They can help reduce SQL complexity! You can break down complex SQL into smaller SQL chunks via temporary tables.
You can find a ton of articles about recursive SQL dating back as early as 2004, but for this article I was asked to provide actual real-world situations where recursive SQL was put to use. In all of the situations it was a great success!
If you are a serious Db2 user, chances are you have downloaded and used free Db2 versions for a few years. Db2 Express-C was a free way to learn Db2 on Linux, Unix and Windows, to practise and test your SQL skills and in later versions implement or ship Db2 with your small production application.
With the SQL OLAP RANK and DENSE_RANK functions being around for a while in SQL programming, it is quite easy to query for the TOP XX from data.
This article is one in a series that focuses on improving performance in Db2 Warehouse. The first part provides some background information and lays out the first and most important aspect of query optimization, namely, cardinality estimation or estimating the number of rows in an execution plan.