plsql - Formatting Clear and readable SQL queries -


I am writing several SQL queries and connects everything a lot, both subquery and the resulting subquery from the table.

We are not using ideas to get out of the question.

After writing it I am seeing it and thinking that it is not even doing it for me. Follow it.

What kind of formatting do you use to try to clean up such a mess? Indents probably?

With great questions, I rely heavily on the named result using I < / Code>. This allows to define the result set in advance and it simplifies the main query. Named result sets can help to make query plans more efficient, such as postgres sets results in the temporary table

Example: cubed_data AS (SELECT dimension1_id, dimension2_id, dimension3_id, measure_id, SUM (value) value From the source_data group, the cube (dimension 1, dimension 2, dimension 2, dimension3), for example:

example: measurement), dimension1_label AS (SELECT dimension1_id, dimension1_label WHERE object = 'dimension 1' ), ... SELECT * FROM to cubed_data join dimension1_label USING (dimension1_id) JOIN dimension 2_label USING (dimension2_id) JOIN dimension 3_label USING (dimension3_id) mea Sure_label USING (measure_id)) The example is a bit contrived, but I hope the comparison of inline subqueries indicates an increase in clarity when I am preparing data for the use of OLAP, So the results set for the name are very helpful for me. Nominated result sets are also required if you have to create recurring questions /

with at least current postgrad, On Oracle and SQL Server If the

Comments