How can i construct this query without using CASE statement?

I've a following code. I'm using this script in Hibernet. So, i cannot use CASE there. Because, hibernet doesn't support case in select statement. How can i construct the same thing which will give me the same result without using CASE?
SELECT ofc.FLT_LCL_ORIG_DT
     , ofc.CARR_IATA_CD
     , ofc.FLT_NBR
     , ofc.ORIG_ARPT_CD
     , ofc.DEST_ARPT_CD
     , sum( ofc.CNCT_PSGR_CNT) AS BOOKED_CNCT_PSGR_CNT
     , sum( CASE WHEN o.fsdr_mrkt_cd = 'D' AND d.fsdr_mrkt_cd = 'D'           THEN '0'
        ELSE to_char(ofc.CNCT_PSGR_CNT,'99')                             END ) AS BOOKED_INTL_CNCT_PSGR_CNT
     , sum(CASE WHEN o.fsdr_mrkt_cd||d.fsdr_mrkt_cd = 'DD'
                THEN '0'
        ELSE to_char(ofc.CNCT_PSGR_CNT,'99')
        END) AS NEW_BCNT
FROM OPS_FLT_CNCT ofc
                    , STN o
                    , STN d
                WHERE ofc.CNCT_ORIG_ARPT_CD = o.STN_CD
                  AND ofc.CNCT_DEST_ARPT_CD = d.STN_CD
                 -- AND TRUNC(ofc.FLT_LCL_ORIG_DT) = trunc(to_date('22-MAY-2007','DD-MON-YYYY'))
                  AND ofc.CARR_IATA_CD = 'UA'
                  AND ofc.FLT_NBR = '1218'
                  AND ofc.ORIG_ARPT_CD = upper('DEN')                AND ofc.DEST_ARPT_CD = upper('IAD')                  GROUP BY ofc.FLT_LCL_ORIG_DT
                       , ofc.CARR_IATA_CD
                       , ofc.FLT_NBR
                       , ofc.ORIG_ARPT_CD
                       , ofc.DEST_ARPT_CD ;And, the output look like this --
FLT_LCL_O CARR FLT_N ORI DES BOOKED_CNCT_PSGR_CNT BOOKED_INTL_CNCT_PSGR_CNT   NEW_BCNT
22-MAY-07 UA   1218  DEN IAD                    9                         0          0
23-MAY-07 UA   1218  DEN IAD                    1                         0          0
24-MAY-07 UA   1218  DEN IAD                    2                         1          1
25-MAY-07 UA   1218  DEN IAD                    1                         0          0Thnaks in advance for reply.
Regards.
Satyaki De.
#####

2 ideas:
1. Inline function to perform the CASE funcionaltity for you
2. Piplelined function to generate the entire dataset
Both will be slower than just using CASE in a query, but we're working around big constraints

Similar Messages

  • How can I fix this select without using subquery?

    Hi guys is there any way to do the where below (in bold) without using an aggregate query before?
    select
    SUM(NET_AMOUNT)
    as net,
    SUM(TAX_AMOUNT)
    as tax,
    SUM(NET_AMOUNT)+
    SUM(TAX_AMOUNT)
    as total from ledger left join alloc on ledger.trxid=alloc.trxid where
     (SUM(NET_AMOUNT)+
    SUM(TAX_AMOUNT))
    > allocated
    net and tax are in the ledger and allocated is in the alloc table. Sometimes the total of the amount (net+tax) is greater than the allocated so I need to retrieve all the rows where allocated is null or  tot is greater than allocated.
    It's possible without CTE?
    Thanks

    Resolved.
    SUM(NET_AMOUNT)
    as net,
    SUM(TAX_AMOUNT)
    as tax,
    SUM(NET_AMOUNT)+
    SUM(TAX_AMOUNT)
    as total from ledger left join alloc on ledger.trxid=alloc.trxid ....group by....
    having ((SUM(NET_AMOUNT)+
    SUM(TAX_AMOUNT))
    > allocated)
    Sometimes I need to post the issue in the forum just to remember how do the things.
    Thanks and sorry

  • I have deleted all my videos songs and photos from my iphone 4 but when i connect to itunes it still shows 17gb free. how can I solve this issue without restore. Total storage of my iphone is 32 gb.

    I have deleted all my videos songs and photos from my iphone 4 but when i connect to itunes it still shows 17gb free. how can I solve this issue without restore. Total storage of my iphone is 32 gb.

    I don't see an issue, but if you mean why didn't you get most of your memory back you need to see what else is using storage. Go to Settings/General/Usage. Wait a bit for it to calculate storage allocation, then when it finishes you can see how much storage each app uses.

  • How can I start windows 8 without useing my password

    how can I start windows 8 without useing my password

    Hi,
    Review the information posted in this thread.
    HP DV9700, t9300, Nvidia 8600, 4GB, Crucial C300 128GB SSD
    HP Photosmart Premium C309G, HP Photosmart 6520
    HP Touchpad, HP Chromebook 11
    Custom i7-4770k,Z-87, 8GB, Vertex 3 SSD, Samsung EVO SSD, Corsair HX650,GTX 760
    Custom i7-4790k,Z-97, 16GB, Vertex 3 SSD, Plextor M.2 SSD, Samsung EVO SSD, Corsair HX650, GTX 660TI
    Windows 7/8 UEFI/Legacy mode, MBR/GPT

  • HT1420 I just bought my cousin's ipod, and I want to update it on my computer.  However, it needs authorization from his account to keep all the apps, and he's already authorized it on 5 computers.  How can I update this ipod without losing all the apps?

    I just bought my cousin's ipod, and I want to update it on my computer.  However, it needs authorization from his account to keep all the apps, and he's already authorized it on 5 computers.  How can I update this ipod without losing all the apps?

    You cannot use someone else's apps without violating the license agreement. The apps are tied to the owner (via Apple ID). The right thing to do would be to update and start fresh.

  • HT4623 I have tried resetting an iPhone 3 and I am unable to activate and sync it. How can I reset the device without using a computer?

    I have tried resetting an iPhone 3 and I am unable to activate and sync it. How can I reset the device without using a computer?

    Hello anacc,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    iOS: Unable to update or restore
    http://support.apple.com/kb/HT1808
    Connect your USB cable to your computer but not to the iPhone, iPad, or iPod touch until step 3.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.If you cannot turn off the device using the slider, press and hold the Sleep/Wake and Home buttons at the same time. When the device turns off, release the Sleep/Wake and Home buttons.
    While pressing and holding the Home button down, connect the USB cable to the iPhone, iPad, or iPod touch. The device should turn on.
    Continue holding the Home button until you see the Connect to iTunes screen. When this screen appears, you can release the Home button:
    Note: If the image of a battery appears, let the device charge for at least ten minutes to ensure that the battery has some charge, and then start with step 2 again. If you don't see the Connect to iTunes screen, try these steps 1 through 4 again.
    iTunes should automatically open and display the following message:
    "iTunes has detected an iPhone in recovery mode. You must restore this iPhone before it can be used with iTunes."Note: If iTunes not open after two minutes, please open iTunes yourself.
    Use iTunes to restore the device.
    Best of luck,
    Mario

  • I want to download an audiobook, but my daughter has a giftcard credit on the account. How can I download my audiobook without using the money from her giftcard?

    I want to download an audiobook, but my daughter has a gift card on the account.  How can I download my audiobook without using the money from her gift card?

    go directly to your ibook app. and you're going to find it. it's only with ibooks app.
    best
    Olivier
    <Edited by Host>

  • In disk utility, it shows that my external hard drive is somehow unmounted and I can't access it in finder or repair it in Disk Utility. How can I get this working without losing my important data?

    In disk utility, it shows that my external hard drive is somehow unmounted and I can't access it in finder or repair it in Disk Utility. How can I get this working without losing my important data?
    Thank you!

    When you erased the disk did you select Mac OS Extended Journaled as the format option?

  • How can i improve this query.

    Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
    select *
    from tableA A, viewB B,
    where A.key = B.key
    and a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    one more thing should function should be on left side of equal sign.
    will a join make it better or something else is needed more than that .

    952936 wrote:
    Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
    select *
    from tableA A, viewB B,
    where A.key = B.key
    and a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    one more thing should function should be on left side of equal sign.
    will a join make it better or something else is needed more than that .If you are a beginner try to learn the ANSI Syntax. This will help you a lot to write better queries.
    Your select would look like this in ANSI.
    select *
    from tableA A
    JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_function(a.key);The good thing here is that this separates the typical joining part of the select from the typical filter criteria.
    The other syntax very often let you forget one join. Just because there are so many tables and so many filters, that you just don't notice correctly anymore what was join and what not.
    If you notice that the number of column is not what you expect, you can easiely modify the query and compare the results.
    example A
    Remove View B from the query (temporarily comment it out).
    select *
    from tableA A
    --JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    example B
    You notice, that values from A are missing. Maybe because there is no matching key in ViewB? Then change the join to an outer join.
    select *
    from tableA A
    LEFT OUTER JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)(The outer keyword is optional, left join would be enough).

  • I deleted the font section but everything in Photoshop CS5 works.  How can I fixed this because I use fonts all the time? I don't want to purchase another one since this cost me $699:(

    I purchased PhotoshopCS5 Sept 2010 and still use the same MAC. I invertly deleted the font section but everything else works.  How can I fixed this because I use fonts all the time? I don't want to purchase another one since this cost me $699:(

    Which version of mac os x are you using?
    Could you clarify what you mean by "I invertly deleted the font section"

  • When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    Chewning wrote:
    I saved some of my music to a Cloud I can't access. Now, they show up as "Purchased" in iTunes, and I'm not given the option of re-downloading OR repurchasing them.
    Music purchased from the iTunes store is not stored in your personal iCloud account, and an iCloud account is not required to redownload them.  You should be able to redownload them as explained here: http://support.apple.com/kb/ht2519.  If you are unable to, contact iTunes store support for assistance by going to https://expresslane.apple.com ; click ‘iTunes', and then 'iTunes Store', then 'Purchases, Billing & Redemption'.

  • How can you search this forum without searching all the other forums

    how can you search this forum without searching all the other forums at the same time which is a big fat waste of time.

    Follow this tip to create a bookmark to a search page that searches only the forum you want or...
    Browse with Firefox and enable this Greasemonkey script, which forces all searches from a sub-forum to be local.

  • Can anyone tell me how can i optimize this query...

    Can anyone tell me how can i optimize this query ??? :
    Select Distinct eopersona.numident From rscompeten , rscompet , rscv , eopersona , rscurso , rseduca , rsexplab , rsinteres
    Where ( ( (LOWER (rscompeten.nombre LIKE '%caracas%') AND ( rscompeten.id = rscompet.idcompeten ) AND ( rscv.id = rscompet.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.nombre) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.lugar) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rseduca.univinst) LIKE '%caracas%)' AND ( rscv.id = rseduca.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsexplab.nombempre) LIKE '%caracas%' AND ( rscv.id = rsexplab.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsinteres.descrip) LIKE '%caracas%' AND ( rscv.id = rsinteres.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscv.cargoasp) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona ) )
    OR ( LOWER (eopersona.ciudad) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona )
    PLEASE IF YOU FIND SOMETHING WRONG.. PLEASE HELP ME.. this query takes me aproximatelly 10 minutes and the database is really small ( with only 200 records on each table )

    You are querying eight tables, however in any of your OR predicates you're only restricting 3 or 4 of those tables. That means that the remaining 4 or 5 tables are generating cartesian products. (n.b. the cartesian product of 5 tables with 200 rows each results in g 200^5 = 320,000,000,000 rows) Then you casually hide this behind "distinct".
    A simple restatement of your requirements looks like this:
    Select eopersona.numident
      From rscompeten,
           rscompet,
           rscv,
           eopersona
    Where LOWER (rscompeten.nombre) LIKE '%caracas%'
       AND rscompeten.id = rscompet.idcompeten
       AND rscv.id = rscompet.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.nombre) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.lugar) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    ...From there you can eliminate redundancies as desired, but I imagine that the above will perform admirably with the data volumes you describe.

  • Firewall stops Firefox from loading any websites... had to switch off security to send this message... How can I fix this? Am using Symantec Client Firewall

    Firewall stops Firefox from loading any websites... had to switch off security to send this message... How can I fix this? Am using Symantec Client Firewall

    This forum is only for discussions on the forums themselves. You should post your question in the apropriate product forum,
    http://forums.adobe.com/community/shockwave
    if your ptoblem is with Shockwave, or
    http://forums.adobe.com/community/flashplayer
    if it affects Flash Player.

  • HT2589 how can i create apple id without using credit card details ?

    how can i create apple id without using credit card details ?

    @Limnos - that doesn't work anymore. There is no NONE option. I've been at it for hours trying to set up my daughter's account. I've tried creating and verifying an appleID on the web, on her touch...everything. Every single time you get to the stupid Touch, it wants to walk you through the verification of the account and it demands payment (even for their suggested apple Remote method listed in the KB).

Maybe you are looking for

  • Questions on Report Builder and Graphics Builder

    Hi there: I'm currently using Report/Graphics builder V 6.0.8.11.3 NT version to create RDF and OGD files. I was wondering with the following confusions: 1) Is the RDF/OGD file that I create under NT plat form portable to Sun Unix?? (ie. would Report

  • User exit to copy the data from sales order to billing document

    hi everyone, Is there an user exit to copy the data from sales order to billing document? Regards Prabudh

  • Cancel MobileMe Gallery sync and how do I rename a synced Album?

    I seem to have uploaded a large number of Albums with a large number of images and want to cancel this sync. I selected each and went to Delete and this does not seem to do it. Is there a better way to do this either through MobileMe or through iPhot

  • Auto send CRM Appointments

    I have a workflow that creates appointments in CRM 2011.  The appointment is created setting a user as the organizer. The issue is that the appointment syncs to the Outlook client, and the user needs to open it on their Outlook calendar and click sen

  • Backup Without giving username and password

    Dear Friends, I am using Oracle 10g. I created a batch file to make export backup. In the batch file i have to mention username and password. Whereas i don't want to mention username and password so that nobody can see that. Is there any option to do