Decode () can only create new columns (horizontal scaling), while the max () function is used to reduce the number of rows of the same category (vertical compression ), in this way, the original thin database record set is converted into a relatively flat matrix record set.
There are only four ways to reduce the number of records: Where, minus, grouping, distinct: Remember that the corresponding Oracle exists. in SQL, only select case end can be written ....
Select CP product, decode (LB, 'A', SL, null) a quantity, decode (LB, 'A', je, null) A amount,
Decode (LB, 'B', SL, null) Quantity of B, decode (LB, 'B', je, null) Amount of B,
Decode (LB, 'bing', SL, null) a quantity, decode (LB, 'bing', je, null) C amount,
Decode (LB, 'dd', SL, null) a quantity, decode (LB, 'dd', je, null) d Amount
From AAA;
---------------------------------------------------------------------
Product a quantity a amount B Amount B amount a amount C amount a amount d Amount
---------------------------------------------------------------------------------------
Product A 1 2
Product B 2 3
Product c 3 4
Product D 1 4
Product A 2 6
Product c 3 6
Product E 4 5
Product A 5 4
Product D 6 4
Product B 1 3
---------------------------------------------------------------------
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.