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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:54:04+00:00 2026-05-22T00:54:04+00:00

a) There are 2 tables: CDR and CR. I need to get sum nominal

  • 0

a) There are 2 tables: CDR and CR. I need to get sum nominal from CR and sum of OS from CDR

b) In table CDR, I will need to create the category field Which will then use for group by: PDT,TAG,ARR,BUCKET

c)

Table CDR:

ID     NOMINAL
1      800
2      700
3      900
3      1000
4      760
5      666

Table CR:

ID    POOL_CD     EXPOSURE_ATT     OS      METHOD     BS     ASSET
1     XT11        04               800     ADV        KKK    ZZZ
2     XO21        05               700     K          ABC    NNN
3     XT11        04               300     ADV        GGG    ZZZ
4     X022        04               200     ADV        HHH    ZZZ
5     XT14        05               100     ADV        GGG    ZZZ

Final Table:

PDT      EXPOSURE_ATT      TAG      ARR       BUCKET       OS     NOMINAL
T        04                ALM      1         LE60         1100   2700   (ID 1 AND 3)
T        05                CONV     1         MT90         100    666    (ID 5)
O        04                ALM      2         LE60         200    760    (ID 4)   

SELECT 
CASE WHEN SUBSTR(a.POOL_CD,2,1)='O' THEN 'OVERDRAFT'
    WHEN SUBSTR(a.POOL_CD,2,1)='T' THEN 'TERM_LOAN'
    WHEN (a.exposure_att) in ('04','H3','H4') THEN 'PRIORITY_SEC'
    ELSE 'MASS' END PDT,
CASE WHEN SUBSTR(a.POOL_CD,3,1)='0' THEN '0'
    WHEN SUBSTR(a.POOL_CD,3,1)='1' THEN '1'
    WHEN SUBSTR(a.POOL_CD,3,1)='2' THEN '2'
    WHEN a.POOL_CD='POOL_MY_HL' THEN 'POOL' END ARR,
CASE WHEN SUBSTR(a.POOL_CD,4,1) in ('1','2') THEN 'LE60'
    WHEN SUBSTR(a.POOL_CD,4,1)='3' THEN 'LE70'
    ELSE 'MT90' END BUCKET,
CASE WHEN (a.exposure_att) in ('01','02','04','09','AB') THEN 'ALM'
    ELSE 'CONV' END TAG,
a.Exposure_att,
sum(a.OS) as OS,
sum(b.NOMINAL) as NOMINAL
FROM cdr a left join cr b
on a.ID=b.ID
WHERE a.METHOD = 'ADV' 
AND a.BS not in ('ABC','DEF')
AND a.ASSET = 'ZZZ'
GROUP BY PDT,A.exposure_att,TAG, ARR, BUCKET
ORDER BY PDT,a.exposure_att,TAG, ARR, BUCKET
  • 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-22T00:54:04+00:00Added an answer on May 22, 2026 at 12:54 am

    HI,
    Finally I have tried it out of the above.

    SELECT x.PDT,x.exposure_att,x.TAG,x.ARR,x.BUCKET,SUM(x.OS) OS,SUM(x.NOMINAL) NOMINAL  
    FROM  
    (  
        SELECT *   
        FROM  
        (SELECT a.ID,a.exposure_att,a.OS,a.METHOD,a.BS,a.ASSET,  
            CASE  
            WHEN SUBSTR(a.POOL_CD,7,1)='O' THEN 'OVERDRAFT'  
            WHEN SUBSTR(a.POOL_CD,7,1)='T' THEN 'TERM_LOAN'  
            WHEN (a.exposure_att) in ('04','H3','H4') THEN 'PRIORITY_SEC'  
            ELSE 'MASS_HL' END PDT,  
            CASE  
                WHEN SUBSTR(a.POOL_CD,8,1)='0' THEN '0'  
            WHEN SUBSTR(a.POOL_CD,8,1)='1' THEN '1'  
            WHEN SUBSTR(a.POOL_CD,8,1)='2' THEN '2'  
            WHEN a.POOL_CODE='POOL_MY_HL' THEN 'POOL' END ARR,  
            CASE  
                WHEN SUBSTR(a.POOL_CD,20,1) in ('1','2') THEN 'LE60'  
            WHEN SUBSTR(a.POOL_CD,20,1)='3' THEN 'LE70'  
            ELSE 'MT90' END BUCKET,  
            CASE  
            WHEN (a.exposure_att) in ('01','02','04','09','AB') THEN 'ALM'  
            ELSE 'CONV' END TAG  
        FROM CDR a) a  
        LEFT JOIN  
            (SELECT b.ID,b.NOMINAL  
            FROM CR b) b  
        ON a.ID=b.ID  
        WHERE a.METHOD = 'ADV' 
        AND a.BS_TYPE not in ('ABC','DEF')
        AND a.ASSET = 'ZZZ'
    ) x   
    GROUP BY x.PDT,x.exposure_att,x.TAG, x.ARR, x.BUCKET  
    ORDER BY x.PDT,x.exposure_att,x.TAG, x.ARR, x.BUCKET  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL query which select the record from three tables and there is no relation
One doubt in MSSQL. There are two tables in a databases. Table 1 named
I need to merge two SELECT statements. There are two tables in my database,
I have joining two tables,There are hundreds of records in table a and there
There are two tables: TABLE bills item_id | price c1 | 10000 m1 |
There are 4 tables: Books : id, name, author, ecc... Category : id, name
I'm looking create a piece of jQuery logic that answers: Are there any tables
I have a products schema and some tables there. Each table in products schema
Where is information about user-defined types stored? Are there some tables which contain information
We insert data from a database into a word-document (Word 2007). There are tables

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.