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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:03:43+00:00 2026-06-13T10:03:43+00:00

I am new to Oracle Analytics . Can any one help me to resolve

  • 0

I am new to Oracle Analytics . Can any one help me to resolve the following.

SELECT year,
           month,
           week,
           C.cpg_pk                                                        CPG,
           C.dep_pk                                                        DEPT,
           T.cust_id                                                       CUST_ID,
           D1.r_id                                                         R_ID,
           Decode(d2.at_code, '3', func1.Get_att(d2.at_code, D2.val_code)) AS P1,
           Decode(d2.at_code, '2', func1.Get_att(d2.at_code, D2.val_code)) AS IC,
           Decode(d2.at_code, '1', func1.Get_att(d2.at_code, D2.val_code)) AS B1,
           Decode(func1.Get_att(d2.at_code, D2.val_code), 2, d2.at_code)   AS P2,
           Decode(func1.Get_att(d2.at_code, D2.val_code), 5, d2.at_code)   AS B2,
           Count(DISTINCT A.cust_id)                                       TOTAL_ACC
           ,
           Count(DISTINCT T.txn_pk)
           TOTAL_TXN,
           SUM(am_amount)                                                  TOTAL_AMT
    FROM   t_header T,
           cust_master A,
           tx_details1 D1,
           tx_details2 D2,
           cpg_master C
    WHERE  A.TYPE = 0
           AND T.cust_id = A.cust_id
           AND T.txn_pk = 5001
           AND T.txn_pk = D1.txn_pk
           AND T.txn_pk = D2.txn_pk
           AND D1.cpg_pk = C.cpg_pk
           AND D1.op = 1
    GROUP  BY year,
              month,
              week,
              C.cpg_pk,
              C.dep_pk,
              t.cust_id,
              D1.r_id,
              Decode(d2.at_code, '3', func1.Get_att(d2.at_code, D2.val_code)),
              Decode(d2.at_code, '2', func1.Get_att(d2.at_code, D2.val_code)),
              Decode(d2.at_code, '1', func1.Get_att(d2.at_code, D2.val_code)),
              Decode(func1.Get_att(d2.at_code, D2.val_code), 2, d2.at_code),
              Decode(func1.Get_att(d2.at_code, D2.val_code), 5, d2.at_code) 

Its generated output is as follows:

YEAR    MONTH   WEEK    CPG DEPT    CUST_ID R_ID    P1  IC  B1  P2  B2   TOTAL
2012    08      32     127 -1      10019   3665                     134   23100.09   
2012    08      32     127 -1      10019   3665                     135   23100.09  
2012    08      32     127 -1      10019   3665             723           23100.09  
2012    08      32     127 -1      10019   3665        714                23100.09
2012    08      32     127 -1      10019   3665                  41       23100.09
2012    08      32     127 -1      10019   3665                  42       23100.09
2012    08      32     127 -1      10019   3665     21                    23100.09
2012    08      32     128 -1      10019   3665                      134  23100.09 
2012    08      32     128 -1      10019   3665                      135  23100.09 
2012    08      32     128 -1      10019   3665             723           23100.09 
2012    08      32     128 -1      10019   3665        714                23100.09 
2012    08      32     128 -1      10019   3665                  41       23100.09
2012    08      32     128 -1      10019   3665                  42       23100.09
2012    08      32     128 -1      10019   3665     21                    23100.09

Here the values are repeating. I tried to eliminate the repeating with a group by, but didn’t succeed. Could you help me?

The required output is this:

YEAR    MONTH   WEEK    CPG DEPT    CUST_ID R_ID    P1  IC  B1  P2  B2  TOTAL_AMT
---------------------------------------------------------------------------------
2012    08      32      127 -1      10019   3665    21  714 723  41   134 23100.09
2012    08      32      127 -1      10019   3665    21  714 723  41   135 23100.09
2012    08      32      127 -1      10019   3665    21  714 723  42   134 23100.09
2012    08      32      127 -1      10019   3665    21  714 723  42   135 23100.09
2012    08      32      128 -1      10019   3665    21  714 723  41   134 23100.09
2012    08      32      128 -1      10019   3665    21  714 723  41   135 23100.09
2012    08      32      128 -1      10019   3665    21  714 723  42   134 23100.09
2012    08      32      128 -1      10019   3665    21  714 723  42   135 23100.09

The main thing is year, month, week, cpg, dept, cust_id, r_id, p1, ic, b1, p2, b2 it should be unique row. Is it achievable using analytical functions or do I need to write PL/SQL? is my question is sensable ?

  • 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-13T10:03:45+00:00Added an answer on June 13, 2026 at 10:03 am

    with t1
    as(
    select 2012 YEAR1, 08 MONTH1, 32 WEEK, 127 CPG, -1 DEPT, 10019 CUST_ID, 3665 R_ID, null P1, null IC, 723 B1,null P2, null B2, 23100.09 TOTAL from dual union all
    — select 2012, 08, 32, 127, -1, 10019, 3665, null, null, null, null, 135 , 23100.09 from dual union all
    — select 2012, 08, 32, 127, -1, 10019, 3665, null, null, null , null, 134, 23100.09 from dual union all
    select 2012, 08, 32, 127, -1, 10019, 3665, null, 714 , null, null, null, 23100.09 from dual union all
    — select 2012, 08, 32, 127, -1, 10019, 3665, null, null ,null, 41, null, 23100.09 from dual union all
    — select 2012, 08, 32, 127, -1, 10019, 3665, null, null, null, 42, null, 23100.09 from dual union all
    — select 2012, 08, 32, 127, -1, 10019, 3665, 21 , null, null, null, null, 23100.09 from dual union all
    — select 2012, 08, 32, 128, -1, 10019, 3665, null, null, null, null, 134 , 23100.09 from dual union all
    — select 2012, 08, 32, 128, -1, 10019, 3665, null, null, null, null, 135 , 23100.09 from dual union all
    select 2012, 08, 32, 128, -1, 10019, 3665, null, null, 723 , null, null, 23100.09 from dual union all
    select 2012, 08, 32, 128, -1, 10019, 3665, null, 714 , null, null, null, 23100.09 from dual union all
    — select 2012, 08, 32, 128, -1, 10019, 3665, null, null ,null, 41, null, 23100.09 from dual union all
    — select 2012, 08, 32, 128, -1, 10019, 3665, null, null, null, 42, null, 23100.09 from dual union all
    — select 2012, 08, 32, 128, -1, 10019, 3665, 21 , null, null, null, null, 23100.09 from dual
    )
    select t1p1.YEAR1, t1p1.month1, t1p1.week, t1p1.cpg, t1p1.dept, t1p1.cust_id, t1p1.r_id, t1p1.p1,t1ic.ic, t1b1.b1, t1p2.p2, t1b2.b2, t1p1.total
    from (select YEAR1, month1, week, cpg, dept, cust_id, r_id, p1 , total from t1 where p1 is not null) t1p1,
    (select YEAR1, month1, week, cpg, dept, cust_id, r_id, ic from t1 where ic is not null) t1ic,
    (select YEAR1, month1, week, cpg, dept, cust_id, r_id, b1 from t1 where b1 is not null) t1b1,
    (select YEAR1, month1, week, cpg, dept, cust_id, r_id, p2 from t1 where p2 is not null) t1p2,
    (select YEAR1, month1, week, cpg, dept, cust_id, r_id, b2 from t1 where b2 is not null) t1b2
    where t1p1.year1 = t1ic.year1(+) and t1p1.year1 = t1b1.year1(+) and t1p1.year1 = t1p2.year1(+) and t1p1.year1 = t1b2.year1(+)
    and t1p1.month1 = t1ic.month1(+) and t1p1.month1 = t1b1.month1(+) and t1p1.month1 = t1p2.month1(+) and t1p1.month1 = t1b2.month1(+)
    and t1p1.week = t1ic.week(+) and t1p1.week = t1b1.week(+) and t1p1.week = t1p2.week(+) and t1p1.week = t1b2.week(+)
    and t1p1.cpg = t1ic.cpg(+) and t1p1.cpg = t1b1.cpg(+) and t1p1.cpg = t1p2.cpg(+) and t1p1.cpg = t1b2.cpg(+)
    and t1p1.dept = t1ic.dept(+) and t1p1.dept = t1b1.dept(+) and t1p1.dept = t1p2.dept(+) and t1p1.dept = t1b2.dept(+)
    and t1p1.cust_id = t1ic.cust_id(+) and t1p1.cust_id = t1b1.cust_id(+) and t1p1.cust_id = t1p2.cust_id (+)and t1p1.cust_id = t1b2.cust_id(+)
    and t1p1.r_id = t1ic.r_id(+) and t1p1.r_id = t1b1.r_id(+) and t1p1.r_id = t1p2.r_id (+) and t1p1.r_id = t1b2.r_id(+)
    order by t1p1.YEAR1, t1p1.month1, t1p1.week, t1p1.cpg, t1p1.dept, t1p1.cust_id, t1p1.r_id, t1p1.p1,t1ic.ic, t1b1.b1, t1p2.p2, t1b2.b2
    /

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

Sidebar

Related Questions

I'm Working with a new Oracle DB, with one table having the following indexes:
How I can create procedure with following code because I'm new in oracle always
Hi I am new to Oracle Scheduler. My question is - Can we give
Can anyone share a link to sample (ASP).Net code that uses the new Oracle
I am new to Oracle, I have two tablespaces one for dev and one
I am new to Oracle and hope someone can clarify this scenario for me.
I'm new in Oracle and I got the following issue. Why I must double
I am new to oracle, I have created two tables using following queries, CREATE
I have an Excel file that I need to import into a (new) Oracle
I am new to oracle , i want to create a user named as

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.