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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:30:53+00:00 2026-05-21T14:30:53+00:00

Good day, Here’s what I’m trying to do.. ITEM | CATEGORY | AMOUNT Sponge

  • 0

Good day,
Here’s what I’m trying to do..

ITEM   |   CATEGORY    |    AMOUNT
Sponge         A              29
Sponge         B              32
Sponge         C              33
Sponge         D              34
Rod            A               1
Rod            B               2
Rod            C               3
Rod            D               4

And I wanted the output to look like this:

ITEM    |   A   |  B   |   C   |   D
Sponge     29      32      33      34
Rod        1       2       3        5

I’ve been trying all sorts of combinations of GROUP BY but I can’t seem to get it to work.

  • 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-05-21T14:30:54+00:00Added an answer on May 21, 2026 at 2:30 pm
    SELECT ITEM
          ,MAX(CASE WHEN CATEGORY ='A' THEN Amount END) AS A
          ,MAX(CASE WHEN CATEGORY ='B' THEN Amount END) AS B
          ,MAX(CASE WHEN CATEGORY ='C' THEN Amount END) AS C
          ,MAX(CASE WHEN CATEGORY ='D' THEN Amount END) AS D
    FROM YourTable
    GROUP BY ITEM
    

    Or

    SELECT *
    FROM YourTable
    PIVOT (MAX(AMOUNT) FOR CATEGORY IN ([A],[B],[C],[D])) AS Pvt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a sentence like this: Happy birthday!! I have a good day. :)
Good day, I have a question here. I am trying to fetch image from
Good day, could you please help me look and this code and tell me
Good day, i will try and explain myself here. i am trying to create
Good day, i have a meta like this <meta name=viewport content=initial-scale=1.0, maximum-scale=1.0, user-scalabale=no, width=device-width,
Good day all, I am tasked with building a slider for our site. Here
Good day. In my Drupal site, strange characters appear in text. Like, instead of
Good day. I'm new to C# and trying to call functions from a DLL
Good day! I'm trying to run the same update statement with the same params
Good day. I am trying to fetch an asp.net label control's text value using

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.