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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:42:49+00:00 2026-06-11T14:42:49+00:00

SELECT YEAR ,MONTH ,WEEK ,A.customer_id ,C.CP_PK ,C.DEPT_PK ,decode (e.EN_TYPE,’11’, e.EN_PK ) as COL1 ,decode

  • 0
SELECT 
     YEAR
    ,MONTH
    ,WEEK
    ,A.customer_id      
    ,C.CP_PK
    ,C.DEPT_PK                                  ,decode (e.EN_TYPE,'11', e.EN_PK ) as COL1
    ,decode (e.EN_TYPE,'11', d2.ATTR_PK) as COL2
    ,decode (e.EN_TYPE,'10', e.EN_PK ) as COL3
    ,decode (e.EN_TYPE,'13', e.EN_PK ) as COL4
    ,DECODE (e.EN_TYPE,'13', d2.ATTR_PK) as COL5
    ,COUNT(*)       TXN_COUNT
    ,SUM(A_AMOUNT) TOTAL_AMT
FROM TXN_HEADER  T
     ,CUSTOMER A 
     ,TXN_DETAIL D1
     ,TXN_DETAIL D2
     ,CP_ATTRIBUTE C
     ,GEN_LOOKUP e
WHERE   A.TYPE  =  0            
AND     T.CUSTOMER_ID = A.customer_id
AND     T.TXN_PK= D1.TXN_PK
AND     T.TXN_PK= D2.TXN_PK
AND     D1.CP_PK = C.CP_PK
AND     D1.OPERATION = 1 
and     e.en_code = d2.new_code
AND     T.TXN_PK= 12313
GROUP BY 
     YEAR
    ,MONTH
    ,WEEK
    ,A.customer_id      
    ,C.CP_PK
    ,C.DEPT_PK          
    ,decode (e.EN_TYPE,'11', e.EN_PK ) 
    ,decode (e.EN_TYPE,'11', d2.ATTR_PK)
    ,decode (e.EN_TYPE,'10', e.EN_PK) 
    ,decode (e.EN_TYPE,'13', e.EN_PK) 
    ,DECODE (e.EN_TYPE,'13', d2.ATTR_PK) 

the generated output is as follows

YEAR    MONTH   WEEK    CUSTOMER ID CP_PK   DEPT_PK COL1    COL2    COL3    COL4    COL5    TXN_COUNT   TOTAL_AMT
2012    8   32  119 127 -1              74  61  1   
2012    8   32  119 127 -1  73  63              1   
2012    8   32  119 127 -1          67          1   
2012    8   32  119 128 -1  73  63              1   
2012    8   32  119 128 -1              74  61  1   
2012    8   32  119 128 -1          67          1   

here col1 to col5 is scatterd . I want all the values in a row .

like this

YEAR    MONTH   WEEK    CUSTOMER ID CP_PK   DEPT_PK COL1    COL2    COL3    COL4    COL5    TXN_COUNT   TOTAL_AMT


    2012    8   32  119 127 -1  73  63  67  74  61  1   
    2012    8   32  119 128 -1  73  63  67  74  61  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-06-11T14:42:51+00:00Added an answer on June 11, 2026 at 2:42 pm

    try this

    SELECT 
         YEAR
        ,MONTH
        ,WEEK
        ,A.customer_id      
        ,C.CP_PK                                                            
        ,C.DEPT_PK
        ,min(decode (e.EN_TYPE,'11', e.EN_PK )) as COL1
        ,min(decode (e.EN_TYPE,'11', d2.ATTR_PK)) as COL2
        ,min(decode (e.EN_TYPE,'10', e.EN_PK )) as COL3
        ,min(decode (e.EN_TYPE,'13', e.EN_PK )) as COL4
        ,min(DECODE (e.EN_TYPE,'13', d2.ATTR_PK)) as COL5
        ,COUNT(*)       TXN_COUNT
        ,SUM(A_AMOUNT) TOTAL_AMT
    FROM TXN_HEADER  T
         ,CUSTOMER A 
         ,TXN_DETAIL D1
         ,TXN_DETAIL D2
         ,CP_ATTRIBUTE C
         ,GEN_LOOKUP e
    WHERE   A.TYPE  =  0            
    AND     T.CUSTOMER_ID = A.customer_id
    AND     T.TXN_PK= D1.TXN_PK
    AND     T.TXN_PK= D2.TXN_PK
    AND     D1.CP_PK = C.CP_PK
    AND     D1.OPERATION = 1 
    and     e.en_code = d2.new_code
    AND     T.TXN_PK= 12313
    GROUP BY 
         YEAR
        ,MONTH
        ,WEEK
        ,A.customer_id      
        ,C.CP_PK
        ,C.DEPT_PK          
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

GOT error for the following query in MYSQL(version5.1) SELECT year,month,sum(fact_1),sum(fact_2),sum(fact_3),sum(fact_4) from( select year,month,fact_1,fact_2,0 as
I've made a simple calendar where you can select year and month through a
i have this simple query : SELECT YEAR(P.DateCreated) ,MONTH(P.DateCreated) ,COUNT(*) AS cnt FROM tbl1,
I'm using jQUI DatePicker (DP) with month a year select boxes. When DP is
My goal is to have a user select a year and a month. Translate
This is a question maybe already asked. My query is SELECT Year, Month, Line,
I want to select sql: SELECT year-month from table group by year-month AND order
I have this MySQL query that makes use of MONTH() and YEAR() : SELECT
How could I select parking with id 1 and only the cars of year
I'm trying to do something like this: SELECT MAX( ADDDATE(expirationdate, INTERVAL 1 YEAR), ADDDATE(now(),

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.