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 8330741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:12:29+00:00 2026-06-09T02:12:29+00:00

My question is how do you get row cell output into separate columns to

  • 0

My question is how do you get row cell output into separate columns to make viewing that data more readable.

I have the following SQL Query:

SELECT TD.name AS Conditions, PV.value AS Frequency, MSL.name AS  
Mailing_List_Subscriptions, Count(CI.uid) AS Users_Signup_Count
FROM conditions_interest CI
INNER JOIN profile_values PV
ON CI.uid = PV.uid
INNER JOIN hwmailservice_user_lists MSUL
ON CI.uid = MSUL.uid
INNER JOIN hwmailservice_lists MSL
ON MSUL.list_id = MSL.list_id
INNER JOIN term_data TD
ON CI.tid = TD.tid
WHERE (PV.value = 'daily' OR PV.value = 'weekly') AND CI.email = '1'
GROUP BY PV.value, TD.name, MSL.name
ORDER BY TD.name;

With the following output:

SQL OUTPUT

So all the mailing list subscriptions would have there own separate column with the counts associated with the conditions. So like this:

Conditions Frequency Newsletter Partners Annoucements marketing
Abscessed Tooth Daily 95 91 98 98
Abscessed Tooth Weekly 6 4 7 7

If more clarification is needed I will edit my post.

  • 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-09T02:12:31+00:00Added an answer on June 9, 2026 at 2:12 am

    MySQL does not have a PIVOT function which is what you are doing, so you will want to use a CASE:

    SELECT x.Conditions,
      x.Frequency,
      SUM(CASE WHEN Mailing_List_Subscriptions = 'newsletter' THEN Users_Signup_Count END) newsletter,
      SUM(CASE WHEN Mailing_List_Subscriptions = 'partners' THEN Users_Signup_Count END) partners,
      SUM(CASE WHEN Mailing_List_Subscriptions = 'announcements' THEN Users_Signup_Count END) announcements,
      SUM(CASE WHEN Mailing_List_Subscriptions = 'marketing' THEN Users_Signup_Count END) marketing
    FROM
    (
      SELECT TD.name AS Conditions, PV.value AS Frequency, 
        MSL.name AS  Mailing_List_Subscriptions, 
        Count(CI.uid) AS Users_Signup_Count
      FROM conditions_interest CI
      INNER JOIN profile_values PV
        ON CI.uid = PV.uid
      INNER JOIN hwmailservice_user_lists MSUL
        ON CI.uid = MSUL.uid
      INNER JOIN hwmailservice_lists MSL
        ON MSUL.list_id = MSL.list_id
      INNER JOIN term_data TD
        ON CI.tid = TD.tid
      WHERE (PV.value = 'daily' OR PV.value = 'weekly') AND CI.email = '1'
      GROUP BY PV.value, TD.name, MSL.name
    ) x
    GROUP BY x.Conditions, x.Frequency
    ORDER BY x.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a form that gets output into a table. The
I have a question that how to give cell borders in tablelayout of Android
I have a route defined like this: GET /question/:q_id controllers.Questions.viewQuestion(q_id: Long) Then in my
I have to access the value that underlies the active cell of a DataGrid
Others have asked this question, but there's been no good answers that I can
I'm trying to make a UITableView that when a user selects a cell it
I have a simple query that I can't for the life of my get
I was looking for an anwer to question Get next N elements from enumerable
HTML Javascript question to get the selected value of a input-select I can use
From my question at Get Foreign Key Value , I managed to get the

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.