Add diffrent data under one alias column

Hello Experts,

I am trying to write a statement that will access oracle DB. the statement will show data in alias columns. I have it showing the data, but when I change the CASE statement for a different look up query, but want to put it under the same "END M" column. it creates the M column for the first CASE statement, then create a M_1 for the next one.

Is there any way to have the M_1 fall into the M.

thanks

attached is the query im using
SELECT
  CASE NIINPNO
    WHEN '01Z864686'
    THEN 'M48'
    WHEN '01Z144034'
    THEN 'M45AC'
    ELSE 'NEW NIN'
  END AS "END ITEM" ,
  --COUNT(NIINPNO)  AS "INSPEC QTY",
  SUM(REPAIRQTY+NRTSQTY+CONDEMNQTY) AS "INSPECT QTY",
  SUM(NRTSQTY)                      AS "NARTS",
  SUM(REPAIRQTY)                    AS "REPAIRED",
  SUM(CONDEMNQTY)                   AS "CONDEMN",
  CASE NIINPNO
    WHEN '01Z864686'
    THEN CAST(
      (SELECT SUM(WOQUANTITY)
      FROM LOGMAINT.WORKORDER
      WHERE NIINPNO= '01Z864686'
      GROUP BY NIINPNO
      )AS VARCHAR2(40 BYTE))
    ELSE'0'
  END AS M,
    CASE NIINPNO
    WHEN '01Z144034'
    THEN CAST(
      (SELECT SUM(WOQUANTITY)
      FROM LOGMAINT.WORKORDER
      WHERE NIINPNO= '01Z144034'
      GROUP BY NIINPNO
      )AS VARCHAR2(40 BYTE))
    ELSE'0'
  END AS M
FROM LOGMAINT.WORKORDER
GROUP BY niinpno

Open in new window

LVL 3
karephreIT Specialist (Server Management)Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
I'm not sure if I understand what you are asking for, but if you are trying to merge the two "M" columns into one, this should do the trick:


SELECT
  CASE NIINPNO
    WHEN '01Z864686'
    THEN 'M48'
    WHEN '01Z144034'
    THEN 'M45AC'
    ELSE 'NEW NIN'
  END AS "END ITEM" ,
  --COUNT(NIINPNO)  AS "INSPEC QTY",
  SUM(REPAIRQTY+NRTSQTY+CONDEMNQTY) AS "INSPECT QTY",
  SUM(NRTSQTY)                      AS "NARTS",
  SUM(REPAIRQTY)                    AS "REPAIRED",
  SUM(CONDEMNQTY)                   AS "CONDEMN",
  CASE NIINPNO
    WHEN '01Z864686'
    THEN CAST(
      (SELECT SUM(WOQUANTITY)
      FROM LOGMAINT.WORKORDER
      WHERE NIINPNO= '01Z864686'
      GROUP BY NIINPNO
      )AS VARCHAR2(40 BYTE))
    WHEN '01Z144034'
    THEN CAST(
      (SELECT SUM(WOQUANTITY)
      FROM LOGMAINT.WORKORDER
      WHERE NIINPNO= '01Z144034'
      GROUP BY NIINPNO
      )AS VARCHAR2(40 BYTE))
    ELSE'0'
  END AS M
FROM LOGMAINT.WORKORDER
GROUP BY niinpno

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
karephreIT Specialist (Server Management)Author Commented:
PERFECT THANKS
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.