Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

sql code query!

  • 10-05-2006 12:25pm
    #1
    Closed Accounts Posts: 1,723 ✭✭✭


    Hey I have two select statements below, how do i join them so an extra two columns for "b" and "c" are created.

    Select Count(*), AVG(INT_RTE), SUM(BAL_AMT), SUM(NET_BAL)
    FROM filenamexxx

    WHERE bal_for_int > 0
    and bal_for_int<1000
    And load_last_act<>'d'
    and(period_date='date')

    For the above, i want an extra column created and populated with the value 'B'. So there will be five colums i.e COUNT, INT RATE, BAL AMT, NET BAL and then one added say INT_BAND to be populated with the value B.

    Then i have abother select statement below, but want to join this into the first one so i will have a row underneath the above with the value C populated

    Select Count(*), AVG(INT_RTE), SUM(BAL_AMT), SUM(NET_BAL)
    FROM filenamexxx

    WHERE bal_for_int > 10001
    and bal_for_int<2000
    And load_last_act<>'d'
    and(period_date='date')


    So the table result will be:

    COUNT
    INT RATE --- BAL AMT---NET BAL -- INT_BAND
    133232--- 1123333 --- 3232332 --- 32324 --- B
    121324--- 233323 ---- 232323 ----655655 -- C


Comments

  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    This should do what you want
    Select Count(*), AVG(INT_RTE), SUM(BAL_AMT), SUM(NET_BAL),'B' AS INT_BAND
    FROM filenamexxx

    WHERE bal_for_int > 0
    and bal_for_int<1000
    And load_last_act<>'d'
    and(period_date='date')
    UNION
    Select Count(*), AVG(INT_RTE), SUM(BAL_AMT), SUM(NET_BAL),'C' AS INT_BAND
    FROM filenamexxx

    WHERE bal_for_int > 10001
    and bal_for_int<2000
    And load_last_act<>'d'
    and(period_date='date')


  • Closed Accounts Posts: 1,723 ✭✭✭empirix


    works a treat, thanks really appreciated


Advertisement