column values within a table
A very common coding request is
the desire to count the number of distinct values in a low cardinality
For example, a motor vehicle database may need to know the number of
blue cars in Ohio.
These queries are easily solved by using the Oracle decode built-in
In the code below, we see that we use the
sum and decode functions together.
Here is the
output. Note how the decode
function translates the values for Male “M” into a binary 0 or 1.
That, in turn, allows the SQL to perform the counts of the values.
Here is a sample of the output.
you like Oracle tuning, you might enjoy my latest book “Oracle Tuning: The Definitive Reference” by Rampant TechPress. It’s only
$41.95(I don’t think it is right to charge a fortune for books!) and you
can buy it right now at this link: