Extract the requirement

I have enough wrestleed with that. two tables to join.

tbl_customer (hold unique customer_id)
tbl_accounts (a single customer hold several accounts and accounts are two multiple payment methods).

In the tbl_accounts, there is the following scenario.
Senario 1. a customer who have multiple accounts were also multiple payment methods can be Direct_Debit and check for this customer.
Senario 2. a customer who have multiple accounts also have a payment method, either Direct_Debit or cheque.
Senario 3. a client with an account also have a payment method is Direct_Debit or check.

Here's the requirement 2 extracts.

1. excerpt from customer accounts with the two methods of payment (direct debits and cheque).
2. extract the customer accounts with only the Direct Debit payment method.

I managed to get the first requirement. Customer accounts with the two forms of payment. but wrong wih the second requirement.
SELECT * FROM (
SELECT tc.Advertiser_Id,
       tc.Advertiser_Name,
       tc.Advertiser_Status,      
       MAX( CASE WHEN ta.Payment_Method = 'DD'
                    Then 'x' Else 'others'  End)  || 
       Max( Case When ta.Payment_Method = 'CK'
         THEN   'y' Else 'others'
       End) "Checking",     
       SUM(Fn.Ar_Balance)AR_AMT
From tbl_Accounts ta,
    tbl_customers tc
Where ta.Advertiser_Id = tc.Advertiser_Id
And Ar_Balance != '0'
GROUP BY tc.Advertiser_Id,
         tc.Advertiser_Name,
        tc.Advertiser_Status
   )WHERE "Checking" = 'xy'
Published by: ricard888 on 28/07/2011 05:08

Published by: ricard888 on 28/07/2011 05:11

Published by: BluShadow on July 28, 2011 13:28
addition of {noformat}
{noformat} tags. please read {message:id=9360002} to learn to do this yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Hello

What:

SELECT * FROM (
SELECT tc.Advertiser_Id,
       tc.Advertiser_Name,
       tc.Advertiser_Status,
       MAX( CASE WHEN ta.Payment_Method = 'DD'
                    Then 'x' Else 'others'  End)  ||
       MIN( Case When ta.Payment_Method = 'DD'
         THEN   'y' Else 'others'
       End) "Checking",
       SUM(Fn.Ar_Balance)AR_AMT
From tbl_Accounts ta,
    tbl_customers tc
Where ta.Advertiser_Id = tc.Advertiser_Id
And Ar_Balance != '0'
GROUP BY tc.Advertiser_Id,
         tc.Advertiser_Name,
        tc.Advertiser_Status
   )WHERE "Checking" = 'xy'

However, I think it's a better way:

SELECT       tc.Advertiser_Id
,         tc.Advertiser_Name
,         tc.Advertiser_Status
FROM       From tbl_Accounts     ta
,           tbl_customers     tc
WHERE        ta.Advertiser_Id     = tc.Advertiser_Id
GROUP BY  tc.Advertiser_Id
,         tc.Advertiser_Name
,         tc.Advertiser_Status
HAVING       MIN ( CASE
                     WHEN  ta.Payment_Method = 'DD'
                   THEN  'DD'
                   ELSE  'others'
           END
           )          = 'DD;
AND       COUNT (DISTINCT ta.checking_method)     = 1
;

In this way requires only 1 CASE expression and any subquery.
Also, it avoids the arbitrary codes as 'x' and 'y '.

Tags: Database

Similar Questions

  • Is there a product that can extract DOORS requirements to TestStand so that they do not have to be entered twice?

    Export requirements of DOORS in TestStand and don't allow no changes in condition of TestStand.  All editing must be done in the DOORS and then exported in TestStand.  Is there an application that can bind the two together to respond to this request?

    As already mentioned, there is no tool available that does what you want. The reason is, that manage the requirements with DOORS has an interface standardized, but the description for each test is customized, transition to test description-> test procedure is always personalized as well.

    However, you can create such a tool (or leave some partners to develop a).

    I have to be honest with you: creation of these tools requires good knowledge of the DOORS (or NEITHER requirement Gateway if you use it to extract requirements), TestStand API and a programming language. I suggest the following procedure:

    1 extract the requirements for DOORS (e.g. using NIRG) and create a description of file based to needs. I would use XML.

    2. create a translator of TestStand sequence file. This loads the XML of your temporary file and creates a Sequencefile TS. You will want to define types of step (including code modules) to facilitate the transition. Creation of types of step and Sequence File Translator requires good knowledge of the TS.

    3. create a user interface for TS giving the user the ability to "simply export DOORS to TS test routines. This would include steps 1 and 2 in a request of the end user.

    Please note that especially the second part of step 2 shows why NOR does not provide a standard product for this approach.

    hope this helps,

    Norbert

  • Cannot extract the zipped files

    I can't extract the zipped files.  An audio file on my desktop as one. MP3.zip file, and when I right click on it, there is no option to extract the file.  I have compressed folders that contain pictures and tried to unzip them without success.  There is no option in the menu "right click" to extract the selected file.  My windows lack extraction or unzipping option?  Help, please!

    Hello

    Maybe the file is not a real. ZIP file - try to download another. ZIP and save it - so go ahead and
    Click right on and see if there is an option/unzip Unzip (unpack). If yes then you must check with
    the site where you got the. MP3.zip file to see how to handle. Maybe rename it to filename.mp3
    HOWEVER filename.zip will work.

    Download this small utility which is very convenient and comes in. ZIP format just to see if your. ZIP functions
    actually work. You can keep the utility or delete, it requires no installation and is very low.

    What is there in the Startup - free
    http://www.NirSoft.NET/utils/what_run_in_startup.html

    Download - SAVE - go where you put it - right click on and search for decompress/unzip options.

    ==================================

    IF you have ZIP 3 1 problem here you should fix it up:

    How to restore Vista built-in ZIP files Support
    http://www.Vistax64.com/tutorials/65254-zip-file-support-restore.html
    How to enable or disable the files compressed in Vista
    http://www.Vistax64.com/tutorials/93827-zip-file-compressed-folders.html
    Restore the Type Associations by default Vista file extensions
    http://www.Vistax64.com/tutorials/233243-default-file-type-associations-restore.html

    ---------------------------------

    How Unassociate a Type of Extension file in Vista - and a utility to help
    http://www.Vistax64.com/tutorials/91920-unassociate-file-extention-type.html
    Restore and return the file Association in Windows Vista if Original
    http://www.mydigitallife.info/2008/06/22/restore-and-reset-file-association-in-Windows-Vista-back-to-original-default/

    Reset and Fix Broken Windows Vista file Ext and Type Associations (include EXE, COM, SYS, ZIP, LNK,
    Folder, drive)
    http://www.mydigitallife.info/2008/06/22/reset-and-fix-broken-Windows-Vista-file-ext-and-type-associations-include-exe-com-sys-zip-lnk-folder-drive/

    For Windows Vista file association problems
    http://www.Winhelponline.com/articles/105/1/file-association-fixes-for-Windows-Vista.html

    I hope this helps.

    Rob - bicycle - Mark Twain said it is good.

  • pmhome_2000.exe fails to extract the file for installation

    Does anyone else have problem with new version 2 of the software PMB download file pmhome_2000.exe giving message on do not extract?

    Hi tewilbrxx1,

    Check if your computer meets the requirements of the Software House PlayMemories. System requirements is mentioned on the page below:

    http://support.d-Imaging.Sony.co.jp/www/disoft/int/playmemories-Home/Introduction/OS.html

    If my post answered your question, please mark it as "acceptable Solution".

  • Creative cloud error "Unable to extract the files."

    I get an error saying "Unable to extract the files" when I try to install Lightroom CC 2015. I went to/private/tmp and found the installer and tried to run but the installation ends at 0% progress and linked me to a file summary.htm. Files summary.htm has "Requirements", written in it and nothing else. I check my system and I am well above the recommended level. What is my OS? I'm on Mac OS X 10.11.2 while the downloaded file creative cloud is Lightroom 6 LS11, who is old enough.

    Even if we run tool Adobe Cleaner, it will simply remove applications installed, but not Adobe under libraries.

    We have to remove it manually.

    Try the steps marked as a correct answer.

    https://forums.Adobe.com/thread/2010818

  • extract the window just constantly said ' Hi welcome Extract. Loading in progress... " ?  @ DW 2015 still unable to load any file psd? How to solve it?

    extract the window just constantly said ' Hi welcome Extract. Loading in progress... " ?  @ DW 2015 still unable to load any file psd? How to solve it?

    This error seems to be corrected if you

    1. sign up for an Adobe ID on Adobe.com

    2. click on the link in the email that is sent to you as a result of registration which requires you to verify that you have registered the account.

    3. open Dreamweaver CC 2015

    4. open a document (you could open just a simple HTML document empty

    5. go to the navigation menu and open the WINDOW, make sure you are logged in with your Adobe ID, otherwise click Connect and connect.

    6. a window should appear asking you if you want to synchronize your settings.  Check the box for always do and click the sync button now automatically

    7. go to Window\Extract - the extract window should open with the tutorial

    8. Select DOWNLOAD PSD... This should not open the window instead of getting an error on LOADING...

    I hope this solves your problems... otherwise try to connect to 2015 CC of Dreamweaver, Dreamweaver CC 2015 closing, wait a minute or 2 and start over at step 3 above.

    It worked for most of my students.

  • Extract the first letter of each word

    Hi all

    I have a requirement to extract the first letter of each word as shown in the example below
    input: abcd output: a
    input: abcd efgh output: ae
    input: abcd efgh ijkl output: aej
    any help will be much appreciated

    I'm on the 11g version of the db

    Depends on your definition of a "word", but for example:

    SQL> select trim(regexp_replace(' a abcd efgh ijkl','(\S)\S*\s*','\1'))
      2  from dual
      3  ;
    
    TRIM(REGEXP_REPLACE('AABCDEFGH
    ------------------------------
    aaei
     
    
  • Extract the value after the period

    Hello

    I am trying to extract the value from each period.

    I have the table data is stored in this mode 172.168.15.10, which is an IP address,.


    My requirement is I need to first value in a query with must return 172
    If I need the value after the second period, it should return 168


    Please suggest me how to write a SQL for the above requirement and oracle 11i Enterprise edition as the database.


    Thank you
    Sudhir

    with regexp

    select
      regexp_substr('172.168.15.10', '\d+', 1, :pos) s
    from dual
    

    without regexp

    select
      substr(s
            , instr(s, '.', 1, :pos) +1
            , instr(s, '.', 1, :pos + 1) - instr(s, '.', 1, :pos) -1
      ) s
    from (select '.'||'172.168.15.10'||'.'
     s  from dual)
    

    Edited by: chris227 the 01.10.2012 01:23

  • Problems while extracting the hours of the Date field

    Hi guys,.

    We hope that you do well.

    I am facing some problems during extraction of the hours of the date field. Here is an example of my orders table:-

    Select * from orders;

    Arrival time of Order_NO product name
    1 computer Office November 20, 10 10:10
    2 November 21, 10 17:26:34 portable
    3 22 January 11 printer 08:10

    Earlier, it is stated that the daily number of orders take place in the roll of the order, I used to write a query

    arrival_time > = trunc ((sysdate-1), 'DD')
    and arrival_time < trunc ((sysdate), 'DD')

    The above query gives me yesterday how many orders have been been held.

    Now I have the new requirement to report on every 4 hours the number of orders will be held. For example if the current time is 08:00 IST then the query must extraction from 04:00 until 08:00 how many orders took place. The report will take place at 12:00 IST which will give me an order took place from 08:00 until 12:00.

    The report will be run every 4 hours per day and generate report of orders taken place for the past 4 hours. I have a programmer who will run this query every hour, but how to understand to get the order at the request of details who arrived for the past 4 hours. I'm not able to do this using trunc.

    Can you please help me how to make this happen. I checked "Extract" also, but I am not convinced.

    Help, please.

    Thanks in advance
    Aalami

    try something like

    with testdata as (
      select sysdate - level/24 t from dual
      connect by level <11
    )
    
    select
      to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS') s
    , to_char(t, 'DD-MM-YYYY HH24:MI:SS') t from testdata
    where
    t >= trunc(sysdate, 'HH') - numtodsinterval(4, 'HOUR')
    
    S     T
    19-06-2012 16:08:21     19-06-2012 15:08:21
    19-06-2012 16:08:21     19-06-2012 14:08:21
    19-06-2012 16:08:21     19-06-2012 13:08:21
    19-06-2012 16:08:21     19-06-2012 12:08:21
    

    trunc (, 'HH') truncates the minutes and the seconds of the date.
    Extract the hour only works on timestamps
    concerning

    Published by: chris227 on 19.06.2012 14:13

  • David Powers Lesson10 - "does not meet the requirements of an image.

    Hello

    I have a problem to download lesson10 image. It still shows the error message "not satisfying the requirements of an image" even the size of the image, the width and height to meet validation. This is upload_images.php

    My download file size is 160K with 640 pixels wide and 480 pixels high. Help, please. Thank you.

    upload_images.php

    ----------------------

    <? PHP

    $uploader = new Zend_File_Transfer_Adapter_Http();

    $uploader-> setDestination ($destination);

    $uploader-> setOptions (array ('ignoreNoFile' = > TRUE));

    $files = $uploader-> getFileInfo();

    $filenum = 1;

    foreach ($files as $file = > $info) {}

    $file = 'picture {$filenum} ";

    $caption = $_POST ['caption {$filenum}"];

    If (isset($_POST["place_id{$filenum}"])) {}

    $place_id = $_POST ['place_id {$filenum}"];

    } else {}

    $place_id = NULL;

    }

    $filenum ++;

    If ($uploader-> {isUploaded ($file))}

    $filename = $uploader-> getFileName ($file, FALSE);

    $uploader-> addValidator ('Size', FALSE, 500 kB');

    $uploader-> addValidator ('MIME Type', FALSE, 'image');

    $uploader-> addValidator ('ImageSize', FALSE, array ('minheight' = > 50, "minwidth" = > 100 "));

    {If (! $uploader-> {isValid ($file))}

    $errors [$filename] = "$filename does not meet the requirements of an image;

    } else {}

    $no_spaces = str_replace (' ', '_', $filename, $renamed);

    $uploader-> addValidator ('Extension', FALSE, 'gif, png, jpg');

    $recognized = FALSE;

    If ($uploader-> {isValid ($file))}

    $recognized = TRUE;

    } else {}

    $mime = $uploader-> getMimeType ($file);

    $acceptable = array ('jpg' = > ' image/jpeg')

    'png' = > ' image/png ',.

    ('gif' = > ' image/gif');

    $key = array_search ($mime, $acceptable);

    If (! $key) {}

    $errors [$no_spaces] = "$filename is an unrecognized image type";

    } else {}

    $no_spaces = "$no_spaces." $key ';

    $recognized = TRUE;

    $renamed = TRUE;

    }

    }

    If {($recognized)

    get the names of existing files

    $existing = rewinddir(3) ($destination);

    check if the name of the downloaded file is in the table

    If (in_array ($no_spaces, $existing)) {}

    get the position of the last period

    Use it to get the base name and extension

    $dot = strrpos ($no_spaces, '.');

    $base = substr ($no_spaces, 0, $dot);

    $extension = substr ($no_spaces, $dot);

    initialize a counter

    $i = 1;

    use a loop to add the counter after database name

    check if the new name exists in the table

    {}

    $no_spaces = $base. '_' . $i++ . $extension;

    } While (in_array ($no_spaces, $existing));

    $renamed set to true

    $renamed = TRUE;

    }

    $uploader-> clearValidators();

    $uploader-> addFilter ('Rename', array ('target' = > $no_spaces, $info ['tmp_name']));

    $success = $uploader-> receive ($file);

    If (! $success) {}

    $errors [$no_spaces] = implode('.) (', $uploader-> getMessages());

    } else {}

    $uploaded = '$filename downloaded successfully ';

    If {($renamed)

    $uploaded. = "and renamed $no_spaces.

    }

    $images [] = array ('name' = > $no_spaces,)

    'caption' = > $caption,

    ('place_id' = > $place_id);

    $messages [] = $uploaded;

    }

    }

    }

    }

    }

    I finally solved it. For your information, I use php version 5.4.3 and MAMP 2.2. Here are the changes:

    (1) open the php.ini file

    Search for "extension = php_fileinfo.dll" and delete.

    (2) download the package files GNU for windows http://gnuwin32.sourceforge.net/downlinks/file-bin-zip.php.

    Extract the zip file.

    (3) copy 2 of the file in the extracted, folder/share/file/Magic and... /share/file/Magic.MGC and paste in the folder extra/php/magic

    folder. (Create the magic folder in the new folder).

    (4) stop MAMP all services and services to start.

    It will work for you!

  • To extract the value of particular tag of xmlType

    Hello
    The requirement is to extract the value of the specific tab of an XmlType column.

    Here is the schema of the table:
    CREATE TABLE DTCC_REF)
    MESSAGE XMLTYPE NOT NULL,.
    CashFlowId varchar2 (20)
    )

    This table is already filled with only a value in the Message column. cashFlowId is null for all rows.

    Here are examples of MESSAGE data:
    <? XML version = "1.0" encoding = "UTF-8"? > < env:Envelope xmlns:rm = xmlns:pmnt 'OTC_RM_15-Apr-2005' = xmlns:env 'OTC_Payment_15-Apr-2005' = 'http://schemas.xmlsoap.org/soap/envelope/' xmlns:fpml = "http://www.fpml.org/2004/FpML-4-1" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "OTC_RM_15-Apr-2005... «/OTC/OTC_RM_15-Apr-2005.xsd OTC_Payment_15-Apr-2005... http://schemas.xmlsoap.org/soap/envelope/ /xmls/OTC/soap-envelope.xsd /OTC/OTC_Payment_15-Apr-2005.xsd "> < env:Header > < OTC_RM xmlns =" OTC_RM_15-Apr-2005 "> < manifest > < PaymentMsg > < activity > edit < / activity > < status > Matched < / status > < LinkStatus > Linked < / LinkStatus > < TransType > payment < / TransType > < AssetClass > credit < / AssetClass > < DTCCUserId > 00006151» < / DTCCUserId > < CounterpartyId > 00006132 < / CounterpartyId > < / PaymentMsg > < MsgId > 1 < / MsgId > < / Manifest > < / env:Header > < env:Body > < OTC_Payment xmlns = "OTC_Payment_15-Apr-2005" > < payment > < ReferenceIdentifiers > < TradeId > 1001513 M < / TradeId > < ContraTradeId > CREC5856 < / ContraTradeId > < LinkId > LINKEE1DSL890420 < / LinkId > < MatchId > PYMTEKGDRP784788 < / MatchId > < CashFlowId > 2005/12 / 200INTEUREUR1001513M < / CashFlowId > < 61326151EUR1220 NetId > < / NetId > < GroupRefId > < / GroupRefId > < ContraGroupRefId > < / ContraGroupRefId > < / ReferenceIdentifiers > < TradeDetails > < TradeType > EXOTIC < / TradeType > < TradeDate > 2004 - 09 - 13 < / TradeDate > < EffectiveDate > 2004 - 09 - 14 < / EffectiveDate > < ScheduledTerminationDate > 2014 - 09 - 20 < / ScheduledTerminationDate > < NotionalAmount > < fpml : currency > EUR < / fpml:currency > < fpml: Amount > 6000000.00 < / fpml:amount > < / NotionalAmount > < EffectiveRate > 0.3150000 < / EffectiveRate > < ReferenceEntity > < / ReferenceEntity > < / TradeDetails > < SettlementDetails > < SourceSSI > < / SourceSSI > < DestinationSSI > < / DestinationSSI > < / SettlementDetails > < / payment > < / OTC_Payment > < / env : Body > < / env:Envelope >

    Now, I have to fill out the tag CashFlowId value in column 2 of the table.

    How can I retrieve value da? Plase help me...
    SQL> with dtcc_ref as ( select xmltype('
    
      
        
          
            
              Modify
              Matched
              Linked
              Payment
              Credit
              00006151
              00006161
            
            2
          
          
            
              DTCC
              DTCC00006151
            
            
              
                http://db.com/route
                2005-11-26T13:59:29.593Z
                2005-11-26T13:59:29.593Z
              
              
                www.dtcc.net
                2005-11-26T09:47:00.000-05:00
                2005-11-26T09:47:00.000-05:00
              
            
          
        
      
      
        
          
            
              1006299M
              0900000702811
              LINKEBHBKD364294
              PYMTEKUBMKN02373
              2005/12/200INTUSDUSD1006299M
              61516161USD1220
              
              
            
            
              REC
              
                USD
                625625.00
              
              2005-12-20
              Unknown
              Fixed
            
            
              EXO
              2004-09-30
              2004-09-30
              2009-03-20
              
                USD
                247500000.00
              
              1.0000000
              
            
            
              
              
            
          
        
      
    ') xml from dual
    )
    --
    --
    select trim(x.column_value) CashFlowId
      from dtcc_ref t, xmltable('declare namespace e = "OTC_Payment_15-Apr-2005";
                                //e:OTC_Payment//e:CashFlowId/text()' passing t.xml) x
    
    CASHFLOWID
    ------------------------------------------------------
    2005/12/200INTUSDUSD1006299M
    1 row selected.
    
  • The requirements for the universal Clipboard not correct?

    Hello

    The requirements for the universal Clipboard for iMac is not correct. It should work on my iMac mid 2011, but it doesn't. It works on my Macbook Air mid-2013, so I know it works in general.

    You do not discuss Apple in these forums, we are all users like you.

    If you have any questions please ask, however if you have any comments for Apple please leave at www.apple.com/feedback.

  • I can't install El Capitan, even if my computer has the requirements of law

    Hi guys,.

    We recently bought a second hand apple machine itself. All good, but I have problems during the software update latest El Capitan, I need to install external software.

    I see that all of the requirements, but I feel like I'm right on something really obvious.

    My laptop:

    MacBook Air (mid-2012)

    4 GB memory

    Software OS X 10.8.5

    12.7 GB of free storage

    Requirements on the Web site:

    MacBook Air (late 2008 or newer)

    min. 2 GB memory

    OS X 10.6.8 (or newer)

    free storage of 8.8 GM min.

    Coming to app store/download page via the "software update" button under the symbol apple in the header.

    It downloads and then I get the message "El Capitan is currently not supported. THX."when I try to install.

    Thank you in advance!

    What, exactly, have you downloaded? Is this a app install OS X El Capitan 6.2 GB which is located in your Applications folder? Is it still there? Try the following:

    HD recovery start

    Restart the computer and after the chime hold the Command and R keys until the Menu Utility is displayed.

    Repair

    When the Utility Menu appears, select disk utility and click on the continue button. Disk utility charges and select layouts withdrawal (usually Macintosh HD) the list entry side.  Click the first aid tab, and then click the repair disk button. If disk utility reports any errors that have been corrected, then again run repair disc until no errors are reported. If no errors are reported, click repair permissions . Wait for the process to finish, and then quit disk utility and re-enter the Utility Menu. Select restart from the Apple menu.

    Now, try Setup again.

  • Updating FF 24/25, my browser hang, I uninstall the browser and tried to reinstall, but extract the Setup file and blocks until pls give a solution

    Updating FF 24/25, my browser hang, I uninstall the browser and tried to reinstall, but extract the Setup file and blocks until pls give a solution

    I solved the problem, installed the installer from mode Windows safe.

  • where the requirements for the current download? This used to be posted prominently.

    where the requirements for the current download? This used to be posted prominently.

    See:

    You can find the full version of the latest version of Firefox 24.0 in all languages and for all systems operating here:

Maybe you are looking for