In Rotating SQL graphs horizontally, I have shown how to rotate an ASCII SQL graph into horizontal position.
I was dissatisfied with some parts of the solution, which I will show now how to fix:
- I had to manually scale the graph values so as to fit nicely into screen.
- I had to rely on hard coded scaling schemes.
- I had to rely on hard coded column names.
- I had no y-axis legend.
I will now present an SQL query which allows for pluggable queries, which creates self, auto scaling graphs, along with y-axis scales.
Using deeply nested subqueries, we will evolve a simple SELECT query into an elaborate graph. I will present the many steps required, followed by explanations and sample results. But in the end – the steps are unimportant. I’ll present a generic query, into which your own SELECT can be embedded, and which will provide you with the graph.
We’ll use the same example, found in graph.sql.