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

  • Home
  • SEARCH
  • 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 8302297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:15:19+00:00 2026-06-08T17:15:19+00:00

We have the following data. TestName Stage1 Stage2 Stage3 Stage4 Test1 John Calra John

  • 0

We have the following data.

TestName  Stage1  Stage2  Stage3  Stage4
Test1     John    Calra   John    Calre
Test2     Calra   null    John    Calra

We need to implement a query which show data in below format.

User    Stage1count  Stages2Count  Stages3count  Stages4Count
John         1             0             2             0
Calra        1             1             0             2

Thanks
John

  • 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-08T17:15:20+00:00Added an answer on June 8, 2026 at 5:15 pm

    You could use a union to normalize the data. After that, a regular pivot strategy will work:

    select  Name
    ,       sum(case when Stage = 1 then 1 end) as Stage1count
    ,       sum(case when Stage = 2 then 1 end) as Stage2count
    ,       sum(case when Stage = 3 then 1 end) as Stage3count
    ,       sum(case when Stage = 4 then 1 end) as Stage4count
    from    (
            select  1 as Stage
            ,       Stage1 as Name
            from    YourTable
            union all
            select  2 as Stage
            ,       Stage2 as Name
            from    YourTable
            union all
            select  3 as Stage
            ,       Stage3 as Name
            from    YourTable
            union all
            select  4 as Stage
            ,       Stage4 as Name
            from    YourTable
            ) as SubQueryAlias
    group by
            Name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following data in text file 375020222511963 284970411563422 290245594366931 I need to retrieve
I have following data GROUP_ID INDEX NULL 1 1 2 NULL 3 1 4
I have the following data. I need to query the data so that I
I have following type data for human family: indvidual <- c(John, Kris, Peter, King,
I have following data frames > head(elo) date elo 1 1921-12-18 1597 2 1922-05-14
I have following data structure (simplified): A giant list of the class TestClass public
I have following data to save in database using php my data is :
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
I have following data in excel table r1 r2 r3 r4 r5 v1 v2
I have following data in a file called binFile 78 1 79 4 80

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.