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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:01:37+00:00 2026-05-15T16:01:37+00:00

I hope I’m explaining this well. I’m struggling with this query: I have this

  • 0

I hope I’m explaining this well. I’m struggling with this query:

I have this table that is something like this:

InvoiceNum
Amount
Type  - where type could be item, shipping or tax. 

So what I want returned is one row per invoice: InvoiceNum, ItemAmount, ShippingAmount, TaxAmount.

Here’s an example:

Invoicenum Amount Type
1          $32    Item
1          $2     Shipping
1          $1     Tax 

I would want returned:

InvoiceNum ItemAmount ShippingAmount TaxAmount 
1          $32        $2             $1
  • 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-15T16:01:37+00:00Added an answer on May 15, 2026 at 4:01 pm

    You can summarize rows with group by, and you can select specific rows using case:

    select  InvoiceNum
    ,       sum(case when Type = 'Item' then Amount end) as ItemAmount
    ,       sum(case when Type = 'Shipping' then Amount end) as ShippingAmount
    ,       sum(case when Type = 'Tax' then Amount end) as TaxAmount
    from    YourTable
    group by
            InvoiceNum
    

    The case statement returns null by default, and sum ignores nulls.

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

Sidebar

Related Questions

Hope this is possible- Have a table like so: Car_ID Brand Model Year ----------------------------------
hope someone can help me. I have a function like <script language=JavaScript type=text/javascript> function
hope you can help me. I have html markup like this: <a href=error.htm class=button
Hope I'm asking this correctly: I have a project Projects.Client I have my class
Hope to get solution to this problem. I have been stuck on it since
Hope this is not a dupe. I would like to be able to do
Hope someone has an easy answer on this. I have a header image which
Hope you are fine. My question : In MYSQL i have a table with
hope someone can help with this. I currently have an Add to Cart option
Hope someone can help me out with this one ! I have a sql

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.