Mysql Row to Column

Source: Internet
Author: User


Select* from where a.batch_no = ' ss20170123181418' ;
This is the original data:

This is what it looks like after a row-to-column:
SelectA.debt_type,sum( Case   whenDebt_type='0'   ThenAMOUNTEND)'Initial Debt',sum( Case   whenDebt_type='1'   ThenAMOUNTEND)'Level Two debt' , CONVERT(Group_concat (Debt_type,'Total:', AMOUNT) USING UTF8) as 'Stitching Totals',sum(AMOUNT) as 'Total'   fromT_zg_asset_statistic_info awhereA.batch_no='ss20170123181418'GROUP  byA.debt_typeORDER  byA.debt_type;

PostScript: MySQL blob field to string method
CONVERT (Group_concat (Debt_type,' total:', AMOUNT) USING UTF8)

Mysql Row to Column

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.