the neutrophilia help lines that do not have a match.

I'm having a hell of a time trying to write a select statement that would choose to specific lines without match. hurt after a sample of my table and data below.

creating the table

CREATE TABLE "IDEA"
  (
    "CODE"        VARCHAR2(32 BYTE),
    "ACCOUNTCODE" VARCHAR2(32 BYTE),
    "DRCR"        VARCHAR2(20 BYTE),
    "ENTRYID"     VARCHAR2(32 BYTE),
    "JOURNALAMT"  NUMBER(17,2)
  )

data in the table.

INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172863', '6.27')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172863', '6.28')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '1115', 'CR', '172863', '-12.55')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172899', '0.25')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172899', '0.25')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172899', '197.25')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172899', '197.25')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '1115', 'CR', '172899', '-394.50')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172903', '975')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '7038', 'DR', '172903', '975')
INSERT INTO "IDEA" (CODE, ACCOUNTCODE, DRCR, ENTRYID, JOURNALAMT) VALUES ('Company', '1115', 'CR', '172903', '-1950')

When I run the following query I have that would get the following result

select
    --DRCR,
    ENTRYID,
    sum(JOURNALAMT)
   
From idea
group by entryid

my top of the query output.

"ENTRYID"                     "SUM(JOURNALAMT)"             
"172863"                      "0"                           
"172899"                      "0.5"                         
"172903"                      "0"                          

I want to identify the lines that make up the 50.

Please note that there might be 3 or 4 lines per credit. so it could be a football match of the 4DR same 5DR or 1 CR 1 CR however will always be 1 CR.

I thought to write a plsql program that would try to match every single possible combination for 1 credit, but it seems to me that there is an easier way.

any help would be grateful.

Hello

Here is a function that attempts to find a combination of 'DR' ranks with the entry ID given, whose journalamts correspond exactly to the amount given.  If If is such a combination, it returns a string that contains a list delimited by amounts.  You coould easily change this to return a list delimited by primary keys, or whatever you want:

FUNCTION to CREATE or REPLACE dr_list
(entryid_wanted IN idea.entryid%TYPE
journalamt_wanted in NUMBERS
prev_rowid IN DEFAULT NULL ROWID
)
RETURN VARCHAR2
IS
"failure_message VARCHAR2 (50): = '(aucune correspondance trouvée);
remainder_list VARCHAR2 (4000);
return_list VARCHAR2 (4000);
BEGIN
IF journalamt_wanted > 0
THEN
return_list: = failure_message;   -Are likely to be replaced later

-Find each line that may be part of a solution
FOR (IN) r
SELECT journalamt
R_id AS ROWID
The IDEA
WHERE Drcr = "DR".
AND entryid = entryid_wanted
AND journalamt > 0 - if necessary
LNNVL (ROWID, AND<=>
ORDER BY ROWID
)
LOOP
IF r.journalamt = journalamt_wanted
SO - This line is a solution alone
return_list: = r.journalamt;
EXIT;
On the OTHER - see if this line belongs to a bigger solution
remainder_list: = dr_list (entryid_wanted
, journalamt_wanted - r.journalamt
r.r_id
);
IF remainder_list <> failure_message
THEN
return_list: = r.journalamt | ', ' || remainder_list;
EXIT;
END IF;
END IF;
END LOOP;
END IF;

RETURN return_list;
END dr_list;
/

You can use the function in a query like this:

SELECT EntryID

SUM (journalamt) AS total_amt

, dr_list (entryid, SUM (journalamt)) AS extra_drs

The IDEA

GROUP BY entryid

;

and it could produce an output like this:

ENTRYID TOTAL_AMT EXTRA_DRS
---------- ---------- ------------------------------
172903 0
172863 0
172899.5.25,.25
8 987 (no match)
901 5 2, 2, 1

Note that when you call the function, pass you the arguemnts only 2.  The 3rd argument is used only by the function when it calls itself.

Tags: Database

Similar Questions

  • How to get an average displacement of the last 5 lines that were NOT NULL?

    I have a question involving a moving average, and it works fine using:

    AVG (col_x) more (partition col_a, col_b, col_c lines between 5 preceding and 1 preceding arrested)

    However, I want to change this option to give the average of the last 5 lines which were non-null.  Does anyone know how to do?

    For example:

    create table sample_table)

    col_a varchar2 (10),

    date of col_b,

    col_c number (2),

    col_x number (5.2)

    );

    insert into sample_table values ('X', trunc (sysdate), 1, 1);

    insert into sample_table values ('X', trunc (sysdate), 2, 2);

    insert into sample_table values ('X', trunc (sysdate), 3, 3);

    insert into sample_table values ('X', trunc (sysdate), 4, 4);

    insert into sample_table values ('X', trunc (sysdate), 5, 5);

    insert into sample_table values ('X', trunc (sysdate), 6, 6);

    insert into sample_table values ('X', trunc (sysdate), 7, 7);

    insert into sample_table values ('X', trunc (sysdate), 8, null);

    insert into sample_table values ('X', trunc (sysdate), 9, null);

    insert into sample_table values ('X', trunc (sysdate), 10, null);

    insert into sample_table values ('X', trunc (sysdate), 11, null);

    insert into sample_table values ('X', trunc (sysdate), 12, null);

    insert into sample_table values ('X', trunc (sysdate), 13, null);

    insert into sample_table values ('X', trunc (sysdate), 14, null);

    insert into sample_table values ('X', trunc (sysdate), 15, null);

    Select t.*,

    AVG (col_x) on myavg (partition col_a, col_b, col_c lines between 5 preceding and 1 preceding arrested)

    of sample_table t

    order by 1,2,3;

    COL_A, COL_B, COL_C MYAVG COL_X

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

    X 15/01/2015 1 1.00

    X 15/01/2015 2 2.00 1

    X 15/01/2015 3 3.00 1.5

    X 15/01/2015 4 4,00 2

    X 15/01/2015 5 5.00 2.5

    X 15/01/2015 6 6.00 3

    X 15/01/2015 7 7.00 4

    X 15/01/2015 8 5

    X 15/01/2015 9 5.5

    15/01/2015 X 10 6

    X 15/01/2015 11 6.5

    X 15/01/2015 12 7

    15/01/2015 X 13

    15/01/2015 X 14

    X 15/01/2015 15

    15 selected lines

    What I really want is:

    COL_A, COL_B, COL_C MYAVG COL_X

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

    X 15/01/2015 1 1.00

    X 15/01/2015 2 2.00 1

    X 15/01/2015 3 3.00 1.5

    X 15/01/2015 4 4,00 2

    X 15/01/2015 5 5.00 2.5

    X 15/01/2015 6 6.00 3

    X 15/01/2015 7 7.00 4

    X 15/01/2015 8 4

    X 15/01/2015 9 4

    X 15/01/2015 10 4

    X 15/01/2015 11 4

    X 15/01/2015 12 4

    X 15/01/2015 13 4

    X 15/01/2015 14 4

    X 15/01/2015 15 4

    15 selected lines


    concerning

    Neil

    Hello

    Here's one way:

    WITH got_avg AS

    (

    SELECT T.*

    AVG (col_x) OVER (PARTITION BY col_a, NVL2 (col_x, 1, 0)

    ORDER BY col_b, col_c

    LINES BETWEEN 5 PRECEDING

    AND 1 PRECEDING

    ) AS myavg

    OF sample_table t

    )

    SELECT col_a, col_b, col_c, col_x

    LAST_VALUE (myavg IGNORE NULLS) over (PARTITION BY col_a

    ORDER BY col_b, col_c

    ) AS myavg

    OF got_avg

    ORDER BY col_a, col_b, col_c

    ;

    Too bad, that we cannot use the IGNORE NULLS with AVG function.

  • Get the ROWID of lines that are not not duplicate in Oracle 10 g

    Hello

    given a table TAB1 in which the primary key is composed of the first 3 columns:

    ================================================
    colA___colB___colC___colD
    ================================================
    AA-----------------------01-----------------------20080101-----------------------100
    BX-----------------------32-----------------------20050325-----------------------366
    AA-----------------------01-----------------------20080102-----------------------645
    AA-----------------------01-----------------------20080707-----------------------765
    AB-----------------------02-----------------------20080806-----------------------336
    AB-----------------------02-----------------------20080705-----------------------543

    I want to be able to find the ROWID of these lines where colA | colB occurs only once in the table TAB1.

    So in the example above, I would like to know the ID of the containing colA = BX line and colB = 32 as "BX32" appears only once in this table (AA01 happens 3 times, AB02 occurs twice, so I'm not interested in them).

    The following does not work, but it's too SLOW:

    Select the TAB1 ROWID where colA | colB = (select colA | colB of TAB1 HAVING COUNT (*) = 1).

    Can someone please suggest an effective way to find this unique ROWID value in these circumstances?

    Published by: Nemesis on November 29, 2008 02:50

    Hi Justin:

    Thank you for your support, I didn't know that the separate symbol appears. Sorry for all :)

  • I get that for Windows Server 2003 is no longer supported the KBs on these issues do not have a correction action.

    I get that for Windows Server 2003 is no longer supported the KBs on these issues do not have a correction action. My network is disconnected, so the automatic update is not an option but I always receive as a vulnerability on the scans. How can I obtain the latest CRL to mitigate these vulnerabilities.

    Hello

    Thanks for posting your query on the Microsoft Community.

    I suggest you re-post your query on The TechNet Forums because we have experts working on this type of questions and for you help the better.

    Check out the link:

    https://social.technet.Microsoft.com/forums/Windows/en-us/home?category=w7itpro

    Hope this information helps. Please let us know if you need any other help with Windows in the future. We will be happy to help you.

  • I need to install Flash Player on a computer that does not have internet access. The 'flashplayer18_d_install.exe' I copied everywhere that 'no Internet' computer wants to deal in the internet to do something and of course fails. I need a ins

    I need to install Flash Player on a computer that does not have internet access. The 'flashplayer18_d_install.exe' I copied everywhere that 'no Internet' computer wants to deal in the internet to do something and of course fails. I need an installation file that won't connect to the internet. -help

    Hi colinkerr22,

    Offline installers are displayed at the bottom of the Installation problems | Flash Player | Windows in the section "problems".

    --

    Maria

  • I just got an imac that does not have the option of a cd player, I have my suite adobe on another computer, how to do it on the new computer?

    I bought the adobe suite cs6 some years ago on a cd, installed on another computer, and now I got the imac that does not have a cd player, how do I install the suite adobe on my new computer without having to use the cd?

    Available downloadable Setup files:

    Download and installation help links Adobe

    Help download and installation to Prodesigntools links can be found on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".

  • backup drive died with all my photos adobe has all my photos as thumbnails how do I get the thumbnails to adobe? where are they that do not have the habit of losing their thanks

    backup drive died with all my photos adobe has all my photos as thumbnails how do I get the thumbnails to adobe? where are they that do not have the habit of losing their thanks

    If you mean that the unit containing your photos is dead and that can still be seen in the catalog, I'm afraid, you can't do anything.

    The thumbnails are stored in a cache file that is a sqlite database. Each thumbnail is stored as a binary field in two very small dimensions: 120 x 160 and 240 x 320 pixels. It is not an image format and I don't think there's a way to extract them.

    The cache file is named thumb.5.cache and is located in the catalog folder. You can locate this file in the menu help/information system of the Organizer.

  • can I track a pop3 server on a system that does NOT have the client insta

    Can I track a pop3 server on a system that does NOT have the client.
    With the new serfvice on a system and specifying the name of the intellectual property of a remote control in the config file
    running pop3 system. In the config file, it asks a unsername and password. Is it necessary
    and if so what are the permissions the user must?

    > Can 3.0.3 hyperic Open Source apop monitor (which takes place
    > on 1110. I tried to use the pop3 plugin but got the
    > errors I listed to the original problem. We do not run pop3
    > but run they apop.
    > Is - can anyone help with that?

    The pop3 Checker will not work with apop.  Apop Protocol requires that we send a MD5 hash with the user name.  We can, adding this ability.  In the meantime, you can simply use the Socket TCP Checker to make sure that the port is up and listening.

    -Ryan

  • Wireless devices shows the MAC address for 1 device that does not have an IP address

    I am tracking down each device connected to my router nighthawk and I identified everyone except this. There is a device of Wirelsss appears when I connect to the router that does NOT have an IP address but it has a MAC address. An interesting point is that the router device itself has a number of MAC that is not anywhere in the list of devices. Any ideas what this could be? I have an Extneder range wireless attached Nighthawk also but I already idenfified his IP address and Mac address.

    How a device could have a mac address, but not IP address?

    Why the address of the router device do not show in the list of anywhere?

    Try to turn off the Extender and see if that will fill again.

  • If I buy a used PC that does not have an operating system or OS disc, still has the label of license for windows can download Microsoft windows?

    If I buy a used PC that does not have an operating system or OS disc, still has the label of license for windows can download Microsoft windows?

    N ° you must contact the manufacturer of the computer and asking for a disc of recovery/reinstallation of Windows. Carey Frisch

  • Is there a download from Microsoft which will create a bootable usb media that does not have the drivers?

    Original title: A bootable Windows 7 media

    I work on a Lenovo 2-in-1 with Windows 7 (for games) and 10 (for a normal use) Windows to dual-boot. I created a USB stick with Windows 7 Pro (64 bit) of a legitimate Windows 7 Pro disc. The computer starts on the usb device and plays normally, however, one of the steps asks a driver for cd/dvd and this 2-in-1 (Lenovo Flex 3) doesn't have a built-in CD/DVD. All other drivers are located in a folder system. My question is, given my key Windows 7 can I create a new bootable media that does not demand drivers? Is there a download from Microsoft which will create a bootable usb media that does not have the drivers? I know that I can reinstall the drivers manually after the installation.

    Thank you

    Matt Armshaw

    Windows 7 or Windows 10 come preinstalled?

    If you install Windows 7 on a system that is preinstalled with Windows 10, you must do the following before:

    -Disable the secure boot UEFI

    -Disable the quick start

    -L' install created media can be corrupted.

    How to: Dual Boot Windows 7 or Windows 8 with Windows installed 10 first

    I suggest that you try to create another bootable copy.

  • I bought CS5 on a CD for a long time for my windows 7 PC and I now want to put on my new iMac Yosemite that does not have a CD player running. Can I download it from adobe or from the app store and use my original serial number?

    I bought CS5 on a CD for a long time for my windows 7 PC and I now want to put on my new iMac Yosemite that does not have a CD player running. Can I download it from adobe or from the app store and use my original serial number?

    You can use it only on a Win computer. If you had CS6, you could do a platform Exchange but not with CS5. Here are the details of the exchanges of the platform:

    Exchange a product for a different version of the language or platform

  • How an EIT available transfer a liability that does not have access to the assignment form?


    I have a responsibility that does not have access to the professional assignment form.  However, they need access to the information of the costing which is an additional Type of Information transfer.  How can I give them this EIT without giving them the form of assignment and link the EIT to it?

    There is a Fastpath function which directly opens the assignment of additional information form.

    You can add this function to the menu of the responsibility of the user and then also attach the EIT concerned to this responsibility.

    Shailendra

  • Adobe Illustrator CS6 My trial expired, I need the serial number to complete the installation, but my account does not have the serial number

    Adobe Illustrator CS6 My trial expired, I need the serial number to complete the installation, but my account does not have the serial number

    Find the serial number of your Adobe product quickly

    To the link below, click on the still need help? the option in the blue box below and choose the option to chat...

    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Serial number and activation support (non - CC) chat

    https://helpx.Adobe.com/contact.html?step=PHSP-PHXS_downloading-installing-setting-up_lice nsing-activation_stillNeedHelp

  • How can I load my CS5 on my new laptop that does not have a hard drive?

    How can I load my CS5 on my new laptop that does not have a hard drive?

    Downloads available:

    Download and installation help links Adobe

    Help download and installation to Prodesigntools links can be found on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".

Maybe you are looking for