My other half says I’m losing it. But I think that as an enthusiast kernel developer she doesn’t have the right to criticize people. (“I like user space better!” – she exclaims upon reading this).
Shown below is a (single query) SQL-generated pie chart. I will walk through the steps towards making this happen, and conclude with what, I hope you’ll agree, are real-world, useful usage samples.
+----------------------------------------------------------------------+ | pie_chart | +----------------------------------------------------------------------+ | | | ;;;;;;;;;;;;;;;;;;;;; | | oooooooo;;;;;;;;;;;;;;;;;;;;;;;;;;; | | oooooooooooooo;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | | ooooooooooooooooo ;;;;;;;;;;;;##### | | oooooooooooooo ;############# | | oooooooooooo ############ | | oooooooooooo ############ | | ooooooooooo ########### | | oooooooooooo :::::::::::: | | oooooooooooo :::::::::::: | | ooooooooo::::: :::::::::::::: | | o:::::::::::::::: ::::::::::::::::: | | ::::::::::::::::::::::::::::::::::::::::::::: | | ::::::::::::::::::::::::::::::::::: | | ::::::::::::::::::::: | | | | ## red: 1 (10%) | | ;; blue: 2 (20%) | | oo orange: 3 (30%) | | :: white: 4 (40%) | +----------------------------------------------------------------------+
Requirements
We need a generic query, which returns at least these two columns: name_column and value_column. For example, the following query will do: Continue reading » “SQL pie chart”