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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:08:07+00:00 2026-06-18T00:08:07+00:00

I have the below query that works 100%. SELECT transporttype, concat(MONTHNAME(STR_TO_DATE(month, ‘%m’)), ‘ ‘,

  • 0

I have the below query that works 100%.

SELECT
transporttype,
concat(MONTHNAME(STR_TO_DATE(month, '%m')), ' ', year) AS `month`,
round(sum(cost),0) AS cost
FROM v2ReportingTable
WHERE (transporttype not in ('Extrusions-LongDistance','Extrusions-Shuttle') and urgent='no')
GROUP BY (concat(MONTHNAME(STR_TO_DATE(month, '%m')),' ',year)),transporttype
ORDER BY (concat(MONTHNAME(STR_TO_DATE(month, '%m')),' ',year)), transporttype

This outputs the results in 1 column as below:

enter image description here

How can I manipulate the query so that the output is in columns, so I can graph it. desired output is like:

enter image description here

Help appreciated as always,

Updated to match possible answer from Oscar Pérez

enter image description here

  • 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-18T00:08:08+00:00Added an answer on June 18, 2026 at 12:08 am

    as per @JW, thanks for your assistance.

    SELECT  `month`,
            MAX(CASE WHEN transporttype = 'Inbound' THEN loads ELSE NULL END) `Inbound`,
            MAX(CASE WHEN transporttype = 'LocalGauteng' THEN loads ELSE NULL END) `LocalGauteng`,
            MAX(CASE WHEN transporttype = 'LongDistance' THEN loads ELSE NULL END) `LongDistance`,
            MAX(CASE WHEN transporttype = 'Shuttle-company1' THEN loads ELSE NULL END) `Shuttle-company1`,
            MAX(CASE WHEN transporttype = 'Shuttle-company2' THEN loads ELSE NULL END) `Shuttle-company2`,
            MAX(CASE WHEN transporttype = 'stores' THEN loads ELSE NULL END) `stores`,
            MAX(CASE WHEN transporttype = 'returns' THEN loads ELSE NULL END) `returns`,
            MAX(CASE WHEN transporttype = 'localkzn' THEN loads ELSE NULL END) `localkzn`
    FROM
        (
            SELECT  transporttype,
                    CONCAT(MONTHNAME(STR_TO_DATE(month, '%m')), ' ', year) AS `month`,
                    COUNT(loadnumber) AS loads
            FROM    v2ReportingTable
            WHERE   transporttype not in ('Extrusions-LongDistance','Extrusions-Shuttle') AND
                    urgent='no'
            GROUP BY (concat(MONTHNAME(STR_TO_DATE(month, '%m')),' ',year)), transporttype
        ) aa
    GROUP BY `month`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query below that works but was wondering if there is a
I have the following query that works fine: SELECT NomComplet, IIF(Count(FS3.Index) = 0, '0
I am have this query below that is a drop down for year (from
I have the below mysql query that outputs the below image: select v.invoicenumber, v.invoicedate,
I have below a working query that needs to be simplified. The reason is
I have a query below that I use to retrieve the records not updated
I have the query below that when run it says that 325 rows were
I'm using Sql-Server, and I have the below query which returns all columns that
I have an SQL query (below) that essentially takes a student from tbStudents, and
I have a query that returns a result set similar to the one below:

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.