Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9161367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:57:09+00:00 2026-06-17T13:57:09+00:00

Can any one help me out here with a syntax to split the data

  • 0

Can any one help me out here with a syntax to split the data in a row and see if the splitted data is appearing again the count of that splitted info should be obtained.

If you see the below input table. C1 has a data like ABC, ACD, BCE etc.. I want to split that and have a count for each specific data and also the total count.

Help is appreciated in MYSQL

Query i tried in SQL server: As a new bibe i to MYSQL i was able to get data as whole but i was unable to split. For Example, i know select C1 from inputtable. But i unable to get idea to split the data that a row have in a specified column.

Diagramatical Explanation:

Input Table:

C1        
----------
ABC 
ACD
BCE
NULL
A

Output Table:

Column1            Count            TotalCount
------------------------------------------------------
A                  3                  4
B                  2                  4
C                  3                  4
D                  1                  4
E                  1                  4
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:57:10+00:00Added an answer on June 17, 2026 at 1:57 pm

    Splitting data into an arbitrary number of columns would require stored procedures or some similar uglyness. Splitting into ten columns is possible, but turning these columns into rows so you can aggregate them would again require ugly code. All of this indicates that your schema probably is in violation with the first normal form: you’re storing multiple values in a single table “cell”. Can you modify the schema, or do you have to use that one?

    If you have to use that one, here is some ugly code to get you startet. It produces the requested output on your sample input, as tested on SQLFiddle.

    SELECT q1.chr, COUNT(*), q2.cnt
    FROM ( SELECT SUBSTR(C1, 1, 1) AS chr FROM tab
           UNION ALL
           SELECT SUBSTR(C1, 2, 1) AS chr FROM tab
           UNION ALL
           SELECT SUBSTR(C1, 3, 1) AS chr FROM tab
         ) AS q1,
         ( SELECT COUNT(C1) AS cnt FROM tab ) AS q2
    WHERE q1.chr != ''
    GROUP BY q1.chr
    

    Note that I definitely would not advise you to write things this way. Use a proper database schema instead, where you don’t have to repeat lines a fixed number of times. And also consider using a separate query to fetch the total, as repeating that for every row of the result appears rather pointless.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help out with what im doing wrong here? DEMO HTML <div id=usercurrentccbox>
can anyone help me out with the syntax and example for the target server
Can any one help in transforming my xml though XSLT. I am new to
Can any one help me, i already checked resizing demo but this work through
I can not figure out the syntax for this. Here's my code: $('select[id^=lookup_]').change(function() {
I cannot find the syntax error here. Can anyone please help me to find
Can anyone help me out please? I'm confused. I want to set up my
I am new in Blackberry. Can anyone help me out for following queries? Which
Can anyone help me figure out whats wrong with this piece of xaml code?
I am new in Symbian UIQ. So anyone can help me out about following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.