Mysql query with duplicate results

I have a db that someone else set up that I am querying. It
should have been set up to use a couple of different tables... one
for clients and one for subclients with foreign keys to identify.
However, each row has both the client and subclient which means
there are duplicate clients since a single client may have several
subclients.
So...
My query returns multiple clients where I need only one. I am
guessing I can handle this in a loop with AS2.0 but I can't figure
out how to tell when a unique client is detected. Does this make
sense? Do I need to set my query up differently?

try {
ResultSet rs = DB.exQuery("SELECT max(transaction_date) as lastest_date, transaction_value,transaction_type"
                              + "FROM transaction_log WHERE user_id =" + user.getId() + " AND is_credit = '1'");
if ( rs.next () ) {can you explain
*     trans_date = rs.getString("lastest_date");* // trans_date is a string type or date type... and max(transaction_date) as lastest_date returns which type...
     credit = rs.getString("transaction_value");
     trans_method = rs.getString("transaction_type");
} catch(SQLException ex) {}

Similar Messages

  • SQL Query with wrong result

    Hello.
    I have a query with LEFT OUTER JOIN that I think returns invalid results. Here are the problem details:
    CREATE TABLE DOGERR(
    IdDog INTEGER,
    SfPdg CHAR(1),
    IdVpl INTEGER,
    SfVpGot INTEGER,
    SfZrr CHAR(1)
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (1, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (2, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (3, '$', 1, 2, 'C');
    COMMIT;
    CREATE UNIQUE INDEX DOGERR_PK ON DOGERR(IdDog);
    And now the query:
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    This query should (by my understanding) return only one row in wich the joined subquery columns should be NULL. And indeed query returns only one row on Oracle Database 10g Release 10.2.0.1.0 - Production and on Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = NULL, SFVPGOTJOIN = NULL, SFZRRJOIN = NULL
    But on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production it returns TWO rows:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    And now the interesting part: any of the following modified versions of query works even on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production, although modifications should not modify the result set:
    -- Removed unnecessary WHERE conditions
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3;
    -- Removed unnecessary OR condition in subquery
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    -- Removed columns from joined subquery from SELECT part
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    NOTE: the query itself is a little stupid but this is just to demonstrate the problem. We have faced this problem at a customer with our real-world query.
    So, my question is: why different results ?
    Thanks.
    David

    hi,
    welcome to the forum,
    don't have a solution, but I thought I'd let you know that the first SQL statement only returns 1 row on 10gR2
    SQL> SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGo
    tJoin, T.SfZrr AS SfZrrJoin
      2  FROM DOGERR D
      3  LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
      4  T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
      5  WHERE
      6  D.IdDog = 3
      7  AND D.SfVpGot = 2
      8  AND D.SfZrr = 'C';
         IDDOG S      IDVPL    SFVPGOT S  IDVPLJOIN SFVPGOTJOIN S
             3 $          1          2 C
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

  • How to Transpose the Query with following result

    Dear All,
    Can anyone tell me a method of transposing my result of the following query
    Details can be found at
    http://obiee11ge.blogspot.com/2010/07/how-to-transpose-query-with-following.html
    Regards
    Mustafa

    Hi,
    Try this
    Create a combined request with,
    criteria 1 : Dummy, Revenue (Actual),Cogs(Actual), Opex(Actual), PL(Actual)
    in the dummy column fx enter the value as 'Actual'
    criteria 2 : Dummy, Revenue (Yago),Cogs(YAgo), Opex(Yago), PL(Yago)
    in the dummy column fx enter the value as 'Yago'
    criteria 3 : Dummy,Revenue (Budget),Cogs(Budget), Opex(Budget), PL(Budget)
    in the dummy column fx enter the value as 'Budget'
    Now go to the result columns and set the coumn names (Revenue, Cogs, Opex, PL) for the result set.
    For the Dumny remove the column heading.
    In table view you will get the result.
    Thanks,
    Vino

  • MySQL query not outputting results

    Hi Guys,
    I want to retrieve a record from my database which has the latest date and output its contents onto the webpage. This is what I have done so far:
    ResultSet rs = DB.exQuery("SELECT max(transaction_date) as 'lastest_date',transaction_value,transaction_type"
                                  + "FROM transaction_log WHERE user_id =" + user.getId() + " AND is_credit = '1'");
    try {
         trans_date = rs.getString("lastest_date");
         credit = rs.getString("transaction_value");
         trans_method = rs.getString("transaction_type");
    } catch(SQLException ex) {}It compiles fine but when I run the servlet I get "java.lang.NullPointerException" on line 92 (+trans_date = rs.getString("lastest_date");+). I get the same error even if I add the rs.next() method. Note that the database will always only output ONE record. I checked the MySQL query (ran it on the server directly) and it worked fine.

    try {
    ResultSet rs = DB.exQuery("SELECT max(transaction_date) as lastest_date, transaction_value,transaction_type"
                                  + "FROM transaction_log WHERE user_id =" + user.getId() + " AND is_credit = '1'");
    if ( rs.next () ) {can you explain
    *     trans_date = rs.getString("lastest_date");* // trans_date is a string type or date type... and max(transaction_date) as lastest_date returns which type...
         credit = rs.getString("transaction_value");
         trans_method = rs.getString("transaction_type");
    } catch(SQLException ex) {}

  • Error executing a query with large result set

    Dear all,
    after executing a query which uses key figures with exception aggregation the BIA-server log (TrexIndexServerAlert_....trc) displays the following messages:
    2009-09-29 10:59:00.433 e QMediator    QueryMediator.cpp(00324) : 6952; Error executing physical plan: AttributeEngine: not enough memory.;in executor::Executor in cube: bwp_v_tl_c02
    2009-09-29 10:59:00.434 e SERVER_TRACE TRexApiSearch.cpp(05162) : IndexID: bwp_v_tl_c02, QueryMediator failed executing query, reason: Error executing physical plan: AttributeEngine: not enough memory.;in executor::Executor in cube: bwp_v_tl_c02
    --> Does anyone know what this message exactly means? - I fear that the BIA-Installation is running out of physical memory, but I appreciate any other opinion.
    - Package Wise Read (SAP Note 1157582) does not solve the problem as the error message is not: "AggregateCalculator returning out of memory with hash table size..."
    - To get an impression of the data amount I had a look at table RSDDSTAT_OLAP of a query with less amount of data:
       Selected rows      : 50.000.000 (Event 9011)
       Transferred rows :   4.800.000 (Event 9010)
    It is possible to calculate the number of cells retreived from one index by multiplying the number of records from table RSDDSTAT_OLAP by the number of key figures from the query. In my example it is only one key figure so 4.800.000 are passed to the analytical engine.
    --> Is there a possibility to find this figure in some kind of statistic table? This would be helpful for complex queries.
    I am looking forward to your replies,
    Best regards
    Bjoern

    Hi Björn,
    I recommend you to upgrade to rev 52 or 53. Rev. 49 is really stable but there are some bugs in it and if you use BW SP >= 17 you can use some features.
    Please refer to this thread , you shouldn't´t use more than 50% (the other 50% are for reporting) of your memory, therefor I have stolen this quote from Vitaliy:
    The idea is that data all together for all of your BIA Indexes does not consume more then 50% of total RAM of active blades (page memory cannot be counted!).
    The simpliest test is during a period when no one is using the accelerator, remove all indexes (including temporary) from main memory of the BWA, and then load all indexes for all InfoCubes into ain memory. Then check your RAM utilization.
    Regards,
    -Vitaliy
    Regards,
    Jens

  • Issue with Duplicate Results and Summary Fields

    My report is based on an Access Database. For the purposes of this current issue, there is the Master Table called u201CCnu201D and then a related u201CTable Au201D which includes multiple records related to the Master and also a related u201CTable B,u201D also with multiple records related to the Master.
    For my report, I want to output results from Table B based on criteria in Table A. This naturally produces duplicate output on the report. As a result, the Summary Fields that I want to include are incorrect.
    I have tried multiple combinations of the Select Distinct function, suppression based on u201Cprevious fieldu201D being equal, summary fields, running totals and if-then statements and still cannot find a solution that works in all of the cases involved.
    Below are descriptions of three different scenarios that are occurring:
    EXAMPLE #1: Entry 1 has 2 records in Table A and 2 Records in Table B so "Select Distinct" including the Table B ID # and then a Summary Field for the Total produces the correct results, while a Running Total is Incorrect.
    EXAMPLE #2: Entry 2 has 2 records in Table A and 1 Record in Table B so a suppression formula of the field based on the "Previous =" Table B ID # and the Running Total produce the correct results, while Summary Field is incorrect.
    EXAMPLE #3: Entry 3 has 6 records in Table A and 6 Records in Table B. Neither Summary or
    Running Totals produce correct results.
    I would greatly appreciate any advice in terms of creative formulas, etc. that would help produce correct results here.
    Iu2019ll be pulling my hair out soon! Thanks so much-

    Hi Berry
    Try to create a command with a subquery. The subquery will be returning the the duplicate records and the main query that uses this subquery will find distinct records out of the resultset returned by the subquery.
    Let me know if this helps.
    Regards
    Nikhil

  • Help with duplicate results

    Hi,
    I need help desperately. The following is an example of the data that I have.
    I have two tables one name Customers and the other named Orders. The tables have the following attributes
    CUSTOMER
    CustomerNum, CustomerName, OrderNum
    ORDER
    OrderNum, OrderDesc, CustomerNum
    Bare in mind that the CustomerNum can have multiple customers attached to it, example a whole family (I know bad database design but it's too late to change) Let's use the following info for the tables respectively
    CUSTOMER
    0001 Sharon Bigbsy 1234
    0001 Dale Bigbsy 1235
    0001 Omar Bigbsy 1236
    ORDERS
    1234 Chips 0001
    1235 Gatorade 0001
    1236 Candy 0001
    The query i'm using is select Customer.CustomerNum, Customer.CustomerName, Orders.OrderDesc from CUSTOMER, ORDERS where CUSTOMER.CustomerNum = ORDER.CustomerNum
    The results are as follows
    0001 Sharon Bigbsy Chips 1234
    0001 Sharon Bigbsy Gatorade 1235
    0001 Sharon Bigbsy Candy 1236
    0001 Dale Bigbsy Chips 1234
    0001 Dale Bigbsy Gatorade 1235
    0001 Dale Bigbsy Candy 1236
    0001 Omar Bigbsy Chips 1234
    0001 Omar Bigbsy Gatorade 1235
    0001 Omar Bigbsy Candy 1236
    It's giving all the orders place to each customer name but I need only the following
    0001 Sharon Bigbsy Chips 1234
    0001 Dale Bigbsy Gatorade 1235
    0001 Omar Bigbsy Candy 1236
    I'm using SQL in MS Access 2003. Please disregard the abnormalities of the tables, it's someone else's work I inherited with over 6000 entried.
    Any help will be greatly appreciated

    I know only Oracle solution for this.
    select CustomerNum,
           CustomerName,
           OrderDesc
    from(  select Customer.CustomerNum CustomerNum,
                  Customer.CustomerName CustomerName,
                  Orders.OrderDesc OrderDesc,
                  row_number() over (partition by
                                     Customer.CustomerNum,
                                     Customer.CustomerName
                                     order by OrderDesc) rn
           from CUSTOMER,
                ORDERS
           where CUSTOMER.CustomerNum = ORDER.CustomerNum)
    where rn = 1;Cheers
    Sarma.

  • PHP+MySQL query with empty value

    Hi!
    Software is DW8 with Apache 2.0.48, MySQL ver. 4.0.15a, PHP
    4.2.3.
    We had problem when a submitted value for 'regionID' in the
    submit page
    was left blank and the following error message appears in the
    result page:
    "You have an error in your SQL syntax. Check the manual that
    corresponds
    to your MySQL server version for the right syntax to use near
    'LIMIT 0,
    3' at line 1"
    The problem was solved by adding at the top of the page:
    <?php
    if (isset($_POST['regionID']) &&
    empty($_POST['regionID'])) {
    $_POST['regionID'] = '0';
    ?>
    How to change the above code to retrieve ALL records when an
    empty \
    blank value is submitted for 'regionID'?
    TIA
    Nanu

    bbgirl wrote:
    > Something I picked up at a PHP/MySQL seminar...
    $_REQUEST works in place of
    > either $_GET or $_POST. It basically means use either
    get or post. But it is
    > less precise because it can pick up either variable and
    has to think about the
    > request...
    I'm afraid you've picked up rather poor information.
    $_REQUEST relies on
    register_globals being turned on. Since register_globals is
    considered a
    major security risk, the default setting has been off since
    April 2002.
    Many hosting companies have turned register_globals on, in
    spite of the
    security problems, because so many poorly written scripts
    rely on it.
    The PHP development team has decided to resolve this security
    issue once
    and for all by removing register_globals from PHP 6.
    Forget $_REQUEST. Use $_POST and $_GET always. It's safer,
    and it's
    futureproof.
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • Error In MySQL Query With DATE_FORMAT

    this produses an empty query when it shouldn't. I've made some error when using DATE_FORMAT and filtering by MONTH and YEAR but not sure how to fix it:
    mysql_select_db($database_VALUATIONS, $VALUATIONS);
    $query_valuations = sprintf("SELECT val_Trans_id, DATE_FORMAT(val_Date '%d-%m-%Y'), val_Company_Name, val_Company_Ref, val_Manufacturer, val_Model FROM valuations WHERE val_Company_Ref = %s AND MONTH(val_Date) =  %s AND YEAR(val_Date) =  %s ORDER BY val_Date DESC", GetSQLValueString($colname_valuations, "text"),GetSQLValueString($colname2_valuations, "text"),GetSQLValueString($colname3_valuations, "text"));
    Thanks if anyone knows the answer ......

    I think that works as you say but I still can't get it to work with WHERE clauses for month and year, this tst works:
    <?php require_once('Connections/tallon_admin.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    mysql_select_db($database_tallon_admin, $tallon_admin);
    $query_Recordset1 = "SELECT DATE_FORMAT(val_Date, '%d-%m-%Y') as Date, val_Company_Name FROM valuations";
    $Recordset1 = mysql_query($query_Recordset1, $tallon_admin) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Web Site</title>
    </head>
    <body>
    <?php echo $row_Recordset1['Date']; ?> <br>
    <br>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    mysql_free_result($mysql);
    ?>
    I just can't get it working with a where clause to filter by month, this example returns an empty query when it shouldn't - also tried MONTH(val_Date) = %s
    <?php require_once('Connections/tallon_admin.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname_Recordset1 = "-1";
    if (isset($_GET['month'])) {
      $colname_Recordset1 = $_GET['month'];
    mysql_select_db($database_tallon_admin, $tallon_admin);
    $query_Recordset1 = sprintf("SELECT DATE_FORMAT(val_Date, '%d-%m-%Y') as Date, val_Company_Name FROM valuations WHERE MONTH(Date) = %s", GetSQLValueString($colname_Recordset1, "date"));
    $Recordset1 = mysql_query($query_Recordset1, $tallon_admin) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Web Site</title>
    </head>
    <body>
    <?php echo $row_Recordset1['Date']; ?> <br>
    <br>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    mysql_free_result($mysql);
    ?>

  • Display a query with multiple results and a little addon :D

    Hello everybody,
    I wanna make a JSP page that displays multiple results from a query.
    I wanna those results to appair in a table, a row each one, and also a little "square radio form buttton" that makes me select rows I wanna delete (with another button at the end)
    any idea?
    Better if you post the code, I'm not a good JSP writer
    thanks everybody for your attention and your time
    Kind regards

    You're right.. I'd post nothing..
    But it's all still in progress and I don't know what to post..
    I understand is really difficult to invent some code without an origin (variables, functions, the bean), but also some general info would be really appreciated,also making a streched example if you can..
    REQUESTS:
    1) I need make a new JSP page, where will be visualize rows returned from a precise query selection
    2)I use Beans, and my idea was to create Bean in JSP, open connection, make the query and create "some kind of FOR cycle" that fills a table, row by row
    3)Every row must got a little "radio button" for a delete selection; the delete function will start when I press a specific button in this page(i'll use a servlet for this function)
    4)The biggest and important trouble is HOW to display multiple rows in the Table

  • Query with wrong result

    Hei
    I have created a query, but when I made extraction, the invoice number occur many times, but it should only occur 1 time. The summation of the value it is also many times.
    How do I get the Query made ​​so that the invoice  and amount only appears 1 time, if there is only one piece.
    I assume that it is some markings, I have not been properly plugged.
    BillT   Billing Type    Bill.Doc.     Rj     reason for rej.  Net Value   Curr.  BICat    Billing category  Doc. Date           Profit Ctr
    S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
    S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
    S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
    S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
                                                                                    13920,00   DKK
    I only need Bill.Doc and Net Value once.
    Regards Lone
    Edited by: Lone Holst on Aug 2, 2011 10:50 AM

    Hi,
    After you got the records/data in to the ITAB1.
    assign ITAB1 to ITAB2.
    sort: ITAB1, ITAB2 BY bill_doc.
    delete adjaucent duplicates from ITAB2 comparing bill_doc.
    loop at ITAB2.
    loop at ITAB1 where bill_doc = ITAB2-BILL_DOC.
    ITAB3-NET_VALUE = ITAB3-NET_VALUE + ITAB1-NETVALUE.
    clear ITAB1.
    endloop.
    MOVE-CORRESPONDING ITAB1 to ITAB3.
    append ITAB3.
    clear: ITAB2, ITAB3.
    ENDLOOP.
    Ram.

  • Query with Collapsing Result

    Dear Experts,
    I hope I am now on the right place upon my problem.
    I am generating a query in which I wanted to have a collapsing/expanding result based on the group by from the Document number of Journal entry. But the result I got is on the screenshot below.
    I boxed the doc num of JE = 100646, this is the sample doc that I wanted to have the group by function.
    here is my query:
    SELECT
        T4.Code,
        T0.DocDate as 'Date',
        T0.DocNum,
        T2.DocNum as 'AR Doc.#',
        T0.CardCode as BPCode,
        T3.CardName as BPName,
        T3.Address,
        T0.CounterRef as 'Ref',
        T0.TransId As 'Transaction No.',
        T3.LicTradNum as TIN,
        T1.Debit
    FROM dbo.ORCT AS T0
        LEFT join JDT1 T1 ON T0.DocNum = T1.BaseRef
        LEFT JOIN OINV t2 ON t0.DocNum = t2.ReceiptNum
           LEFT JOIN OCRD T3 ON T0.CardCode = T3.CardCode
           LEFT JOIN OFPR T4 ON T0.FinncPriod = T4.AbsEntry
           Inner JOIN OACT T5 on T1.Account = T5.AcctCode
           where T1.Account='_SYS00000000301' and t4.Code=[%]
    The result that I wanted to have is just like from the incoming payments form where it has that collapsing/expanding result for the purpose of Excel transfer and to return one value for the debit only as per one Journal entry.

    Hi Ramoncito,
    You can group easily in Crystal Report.
    Please try to Create this Report in Crystal.
    Thanks'
    Regards::::
    Atul Chakraborty

  • Simple XMLTABLE query with unexpected results

    I have the following (simplified) query. I have formatted the XML for easy reading in this message but there is no whitespace in the actual query.
    Can anyone tell me why I am receiving no records returned. Expecting one record with the value of 'REJECT'
    Thanks in advance.
    select a.decision
        from XMLTABLE(xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "soap"
                                  , 'urn:schemas-cybersource-com:transaction-data-1.28' as "c")
                   , '/soap:Envelope/soap:Body/c:ReplyMessage'
          PASSING xmltype.createxml('
    <?xml version="1.0" encoding="utf-8" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
       <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-27593971">
         <wsu:Created>2009-06-15T17:49:02.870Z</wsu:Created>
        </wsu:Timestamp>
       </wsse:Security>
      </soap:Header>
      <soap:Body>
       <c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.28">
        <c:merchantReferenceCode>27-0</c:merchantReferenceCode>
        <c:requestID>2450881422960008402433</c:requestID>
        <c:decision>REJECT</c:decision>
        <c:reasonCode>520</c:reasonCode>
        <c:requestToken>Ahj77wSRCbmf6bYuaSwCIJsfFx1osBTY+LjrRekDpt6POYI0kyro9JLBWBORCbmf6bYuaSwCAAAALQX8</c:requestToken>
        <c:purchaseTotals>
         <c:currency>USD</c:currency>
        </c:purchaseTotals>
        <c:ccAuthReply>
         <c:reasonCode>520</c:reasonCode>
         <c:amount>99.50</c:amount>
         <c:authorizationCode>123456</c:authorizationCode>
         <c:avsCode>Y</c:avsCode>
         <c:avsCodeRaw>YYY</c:avsCodeRaw>
         <c:cvCode/>
         <c:cvCodeRaw/>
         <c:authorizedDateTime>2009-06-15T17:49:02Z</c:authorizedDateTime>
         <c:processorResponse>A</c:processorResponse>
        </c:ccAuthReply>
       </c:replyMessage>
      </soap:Body>
    </soap:Envelope>')
          COLUMNS
            decision varchar2(30) PATH '/c:ReplyMessage/c:decision') aScott

    i think that the problem was in
    '/c:replyMessage/c:decision' and not '/c:ReplyMessage/c:decision'
    and
    '/soap:Envelope/soap:Body/c:replyMessage' not '/soap:Envelope/soap:Body/c:ReplyMessage'
    try
    Bye
    Maurizio

  • MYSQL Query with Session Variable

    I would like to log in and after login success php will
    automatically query records using my username as the parameter.
    How can it be done in dreamweaver?
    How can I insert multiple values dependent on what I selected
    on a list/menu?
    Thank you!

    yeow Start by using PreparedStatement in your code.

  • Query with duplicates

    I have a query which basically returns one row (location ID) from the select which is shown below
    SELECT location_id
    FROM tasks
    WHERE container_id = :container_id
    AND task_id = (SELECT MIN(task_id
    FROM tasks
    WHERE container_id = :container_id)
    But my requirement is changing now as i have to select location_id in the main select if i have two or more task_id from the inner select and select location_group on the main select if i have only one task_id from the inner select.
    I hope this clearly defines the question
    Thanks in advance.

    Like this ?
    SQL> create table tasks
      2  as
      3  select 1 task_id, 11 location_id, 21 location_group, 99 container_id from dual union all
      4  select 1, 12, 22, 99 from dual union all
      5  select 1, 13, 23, 99 from dual union all
      6  select 1, 14, 24, 99 from dual union all
      7  select 2, 15, 25, 98 from dual
      8  /
    Tabel is aangemaakt.
    SQL> var container_id number
    SQL> exec :container_id := 99;
    PL/SQL-procedure is geslaagd.
    SQL> SELECT location_id
      2  FROM tasks
      3  WHERE container_id = :container_id
      4  AND task_id = (SELECT MIN(task_id)
      5  FROM tasks
      6  WHERE container_id = :container_id)
      7  /
                               LOCATION_ID
                                        11
                                        12
                                        13
                                        14
    4 rijen zijn geselecteerd.
    SQL> select case count_task_id
      2         when 1 then 'location_group'
      3         else 'location_id'
      4         end what
      5       , case count_task_id
      6         when 1 then location_group
      7         else location_id
      8         end location_id_or_group
      9    from ( select task_id
    10                , location_id
    11                , location_group
    12                , count(task_id) over (partition by task_id) count_task_id
    13                , min(task_id) over () min_task_id
    14             from tasks
    15            where container_id = :container_id
    16         )
    17   where task_id = min_task_id
    18  /
    WHAT                             LOCATION_ID_OR_GROUP
    location_id                                        11
    location_id                                        12
    location_id                                        13
    location_id                                        14
    4 rijen zijn geselecteerd.
    SQL> exec :container_id := 98;
    PL/SQL-procedure is geslaagd.
    SQL> select case count_task_id
      2         when 1 then 'location_group'
      3         else 'location_id'
      4         end what
      5       , case count_task_id
      6         when 1 then location_group
      7         else location_id
      8         end location_id_or_group
      9    from ( select task_id
    10                , location_id
    11                , location_group
    12                , count(task_id) over (partition by task_id) count_task_id
    13                , min(task_id) over () min_task_id
    14             from tasks
    15            where container_id = :container_id
    16         )
    17   where task_id = min_task_id
    18  /
    WHAT                             LOCATION_ID_OR_GROUP
    location_group                                     25
    1 rij is geselecteerd.Regards,
    Rob.

Maybe you are looking for