How to return only 1 row of data

Hi,
My problem if the table looks similar to the 1 below.
ID pay_cycle pymnt_dt
1 PAY 12/01/2006
1 EX 12/05/2006
2 PAY 12/08/2006
If the ID (such as ID 1) has a pay cycle of EX, I only want to get its payment date. I don't want it to return any other rows. However if the ID has no pay_cycle of EX (such as ID 2) I want it to return the pymnt_dt of PAY. Is this possible through SQL? I am planning to place the SQL on a table view.

Hi,
I tried to join the query to other tables but I am getting an invalid column name error
SELECT
C.OPRID ,
A.SHEET_ID ,
A.SHEET_NAME ,
B.NAME ,
A.EMPLID ,
A.SHEET_STATUS ,
A.CREATION_DT ,
A.APPROVAL_DT ,
z.PYMNT_DT
FROM
PS_EX_SHEET_HDR A ,
PS_PERSONAL_DATA B ,
PSOPRDEFN C ,
PS_EX_SHEET_APRVL D ,
( SELECT DISTINCT sheet_id,
pymnt_dt FROM ( SELECT sheet_id,
pay_cycle,
pymnt_dt,
seq_nbr,
line_nbr,
row_number() OVER (PARTITION BY sheet_id ORDER BY pay_cycle DESC) rn FROM ps_ex_sheet_pymnt )
WHERE
rn = 1) z WHERE A.SHEET_STATUS='PD' AND
A.POST_STATUS_EX IN ('P','N') AND
A.APPROVAL_LEVEL IN ('S','T','B','I') AND
D.SHEET_ID = A.SHEET_ID AND
D.APPROVER_TYPE = 'T' AND
D.APPROVAL_STATUS NOT IN ('A', 'D') AND
B.EMPLID = A.EMPLID AND
A.SHEET_ID = z.SHEET_ID AND
z.SEQ_NBR = ( SELECT MAX(SEQ_NBR) FROM PS_EX_SHEET_PYMNT X , PS_EX_SHEET_LINE T WHERE E.SHEET_ID = X.SHEET_ID AND
X.SHEET_ID = T.SHEET_ID AND
X.LINE_NBR = T.LINE_NBR) AND
z.EMPLID = A.EMPLID AND
A.EMPLID NOT IN ( SELECT X.EMPLID FROM PSOPRDEFN X WHERE X.OPRID = C.OPRID) ;

Similar Messages

  • How to return the correct row of data using diffferent conditions?

    I am having some problems with an sql query and I hope someone can help please?
    The data I am using is customers with multiple transactions. If a customer contains one transaction where the transaction type = 'W' then I need to set the output value to be transaction.ValueA. If the customer does not contain any transactions where the transaction type is 'W' then I need to set the output value to be
    the most recent transaction.ValueB where transaction.transaction_date <= customer.cust_mod_date.
    Here is an example of the data. For each test customer 10 and 20 I have put a star against the value I want to return
    CUSTOMER_ID CUST_MOD_DATE TX_DATE      TX_TYPE TX_VALUEA TX_VALUEB
    10          15/07/2009 16/07/2009     A     110      95
    10          15/07/2009 14/07/2009     A     100      90(*)          
    10          15/07/2009 13/07/2009     A     90          10
    10          15/07/2009 12/07/2009     A     80          5
    20          15/07/2009 15/07/2009     A     60          10
    20          15/07/2009 14/07/2009     W     50(*)     20
    20          15/07/2009 13/07/2009     A     40          30
    ie
    CREATE TABLE
    TMP_CUSTOMER (CUSTOMER_ID NUMBER, CUST_MOD_DATE DATE);
    insert into tmp_customer
    values(10, to_date('15/07/2009','dd/mm/yyyy'));
    insert into tmp_customer
    values(20, to_date('15/07/2009','dd/mm/yyyy'));
    CREATE TABLE
    TMP_TRANSACTION (TX_ID NUMBER, CUSTOMER_ID NUMBER, TX_DATE DATE, TX_TYPE VARCHAR2(1), TX_VALUEA NUMBER, TX_VALUEB NUMBER);
    INSERT INTO TMP_TRANSACTION
    VALUES (1,10, to_date('16/07/2009','dd/mm/yyyy'),'A',110,95);
    INSERT INTO TMP_TRANSACTION
    VALUES (2,10, to_date('14/07/2009','dd/mm/yyyy'),'A',100,90);
    INSERT INTO TMP_TRANSACTION
    VALUES (3,10, to_date('13/07/2009','dd/mm/yyyy'),'A',90,10);
    INSERT INTO TMP_TRANSACTION
    VALUES (4,10, to_date('12/07/2009','dd/mm/yyyy'),'A',80,5);
    INSERT INTO TMP_TRANSACTION
    VALUES (5,20, to_date('15/07/2009','dd/mm/yyyy'),'A',60,10);
    INSERT INTO TMP_TRANSACTION
    VALUES (6,20, to_date('14/07/2009','dd/mm/yyyy'),'W',50,20);
    INSERT INTO TMP_TRANSACTION
    VALUES (7,20, to_date('13/07/2009','dd/mm/yyyy'),'A',40,30);
    The query I have so far is
    (SELECT CUSTOMER_ID, CUST_MOD_DATE, TX_DATE, TYPE_FLAG, TX_VALUEA, TX_VALUEB, RN
    FROM (SELECT CUST.CUSTOMER_ID, CUST.CUST_MOD_DATE,TRANS.TX_DATE, TRANS.TYPE_FLAG, TRANS.TX_VALUEA,TRANS.TX_VALUEB,
    ROW_NUMBER() OVER (partition BY TRANS.CUSTOMER_ID ORDER BY TRANS.TX_DATE DESC) RN
    FROM TMP_CUSTOMER CUST,
    --- Return all transactions creating a type_flag field where Y = type W, else N ---
    SELECT CUST.CUSTOMER_ID, TX.TX_DATE, TX.TX_VALUEA, TX.TX_VALUEB, CUST.CUST_MOD_DATE, TX.TX_TYPE,
    CASE WHEN NVL(TX.TX_TYPE,'0') <> 'W' THEN 'N'
    WHEN NVL(TX.TX_TYPE,'0') = 'W' THEN 'Y'
    ELSE 'N'
    END AS TYPE_FLAG
    FROM TMP_TRANSACTION TX, TMP_CUSTOMER CUST
    WHERE TX.CUSTOMER_ID = CUST.CUSTOMER_ID
    AND CUST.CUSTOMER_ID in
    '10','20'
    ) TRANS
    WHERE CUST.CUSTOMER_ID = TRANS.CUSTOMER_ID
    --AND   TRANS.TX_DATE <= CUST.CUST_MOD_DATE
    AND CUST.CUSTOMER_ID in
    ('10','20'
    Can anyone please help with how I extract the record I am looking for
    ie customer 10 has amount 90
    customer 20 has amount 50.
    Thanks :-)
    GB

    SQL> select c_id
      2  ,      cust_mod_date
      3  ,      tx_date
      4  ,      tx_type
      5  ,      tx_valuea
      6  ,      tx_valueb
      7  from ( select c.customer_id c_id
      8         ,      c.cust_mod_date
      9         ,      t.tx_date
    10         ,      t.tx_type
    11         ,      t.tx_valuea
    12         ,      t.tx_valueb
    13         ,      row_number() over (partition by c.customer_id order by t.customer_id, t.tx_date desc) rn
    14         from   tmp_customer c
    15         ,      tmp_transaction t
    16         where  t.customer_id = c.customer_id     
    17         and    t.tx_date <= c.cust_mod_date
    18       )
    19  where case
    20          when tx_type = 'W' then 1
    21          when rn = 1
    22          and  not exists ( select null
    23                            from   tmp_transaction t2
    24                            where  t2.customer_id = c_id
    25                            and    t2.tx_type = 'W'
    26                          )
    27          then 1
    28        end = 1;
          C_ID CUST_MOD_ TX_DATE   T  TX_VALUEA  TX_VALUEB
            10 15-JUL-09 14-JUL-09 A        100         90
            20 15-JUL-09 14-JUL-09 W         50         20
    2 rows selected.

  • How to return only rows belonging to an authenticated user?

    Hi, i have a basic JHeadstart application with a form which is currently returning all the rows of a tasks table containing tasks belonging to users, and allows update and insert of new rows to this table.
    I wish to extend this application to include a basic login screen to authenticate the users initially, and then somehow pass the username onto the Jhs form and have it return only the rows from the tasks table which have a userid matching the login username.
    So basically i want to hide the userid column from displaying on screen, and code the form so that the userid column must always match the login username during any view/update/insert/delete operation the form initiates.
    Currently the users are all separate database users and are not known/controlled by the Jdeveloper app yet, so a database connection based authentication method would be most relevent I believe, however I haven't seen any mention in the DB authentication based blogs regarding using the login information in the application such as restricting the results of a table form in the way described above.
    Any pointers appreciated,
    Thanks

    Hi,
    it's used in conjuction with JAAS / Container managed security. The user requests a page which is within a protected resource and is then prompted to login. Once logged in the user principal is available (can be referenced) in both the user interface and model layers.
    The VPD option is there to reduce the coding required in the ADF model layer.
    This article explains how to get JAAS to use a custom database LoginModule which sits undeneath JAAS.
    http://www.oracle.com/technology/products/jdev/howtos/1013/oc4jjaas/oc4j_jaas_login_module.htm
    This you how to reference the currently logged in user in the various layers within the application:
    http://brendenanstey.blogspot.com/2007/05/j2ee-container-managed-security-how-to.html
    The security setup is also covered in the ADF Developer guide which is here:
    http://download.oracle.com/docs/pdf/B25947_01.pdf
    Brenden

  • How to select only one row

    hello,
    i've got a select query which returns a couple of rows.
    now i would like for the query to return only one row (the first match it can find).
    how do i do that?
    thank you!
    my sample of my data as below , the first and seconde record is equal and i want to display all the colomn for the first row and ignore the second row .
    84A8E46E8C97     9410     20110812
    84A8E46E8C97     9420     20110813
    84A8E46E8C6E     9410     20110816
    84A8E46E8AFA     9400     20110819

    876602 wrote:
    my sample of my data as below , the first and seconde record is equal and i want to display all the colomn for the first row and ignore the second rowThere is no row order in relational database tables. Same query canreturn rows in different order next time you run it unless you specify ORDER BY. Only ORDER BY guarantees order, so when you say first row/second row you must provide ordering criteria.
    SY.

  • How to Return only alpha-numeric Values

    In my query, I want to return only records for which data in a specific column is alpha-numeric. Any records having this field as NULL, or containing symbols, I want to exclude. What's the best way to do this?
    Thanks,
    Brice

    select str from tab1
    where str is not null
    and translate(str, '_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','_') is null
    /Regards
    Dmytro

  • How can I modify this script to return only certain rows of my mySQL table?

    Hi there,
    I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
    My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
    I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
    I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
    $subscriberID = $_POST['subscriberID'];
    Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
    Any help is appreciated.
    <?php
    require_once(dirname(__FILE__) . "/2257safeDBconn.php");
    require_once(dirname(__FILE__) . "/functions.inc.php");
    require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
    * This is the main PHP file that process the HTTP parameters,
    * performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
    * and then serialize the response in an XML format.
    * XmlSerializer uses a PEAR xml parser to generate an xml response.
    * this takes a php array and generates an xml according to the following rules:
    * - the root tag name is called "response"
    * - if the current value is a hash, generate a tagname with the key value, recurse inside
    * - if the current value is an array, generated tags with the default value "row"
    * for example, we have the following array:
    * $arr = array(
    *      "data" => array(
    *           array("id_pol" => 1, "name_pol" => "name 1"),
    *           array("id_pol" => 2, "name_pol" => "name 2")
    *      "metadata" => array(
    *           "pageNum" => 1,
    *           "totalRows" => 345
    * we will get an xml of the following form
    * <?xml version="1.0" encoding="ISO-8859-1"?>
    * <response>
    *   <data>
    *     <row>
    *       <id_pol>1</id_pol>
    *       <name_pol>name 1</name_pol>
    *     </row>
    *     <row>
    *       <id_pol>2</id_pol>
    *       <name_pol>name 2</name_pol>
    *     </row>
    *   </data>
    *   <metadata>
    *     <totalRows>345</totalRows>
    *     <pageNum>1</pageNum>
    *   </metadata>
    * </response>
    * Please notice that the generated server side code does not have any
    * specific authentication mechanism in place.
    * The filter field. This is the only field that we will do filtering after.
    $filter_field = "subscriber_id";
    * we need to escape the value, so we need to know what it is
    * possible values: text, long, int, double, date, defined
    $filter_type = "text";
    * constructs and executes a sql select query against the selected database
    * can take the following parameters:
    * $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
    * $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
    * $_REQUEST["filter"] - the filter value
    * $_REQUEST["pageNum"] - the page index
    * $_REQUEST["pageSize"] - the page size (number of rows to return)
    * if neither pageNum and pageSize appear, we do a full select, no limit
    * returns : an array of the form
    * array (
    *           data => array(
    *                array('field1' => "value1", "field2" => "value2")
    *           metadata => array(
    *                "pageNum" => page_index,
    *                "totalRows" => number_of_rows
    function findAll() {
         global $conn, $filter_field, $filter_type;
          * the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
         $fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         $order = "";
         if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
              $order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //get the page number, and the page size
         $pageNum = (int)@$_REQUEST["pageNum"];
         $pageSize = (int)@$_REQUEST["pageSize"];
         //calculate the start row for the limit clause
         $start = $pageNum * $pageSize;
         //construct the query, using the where and order condition
         $query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
         //if we use pagination, add the limit clause
         if ($pageNum >= 0 && $pageSize > 0) {     
              $query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
         $recordset = mysql_query($query_recordset, $conn);
         //if we have rows in the table, loop through them and fill the array
         $toret = array();
         while ($row_recordset = mysql_fetch_assoc($recordset)) {
              array_push($toret, $row_recordset);
         //create the standard response structure
         $toret = array(
              "data" => $toret,
              "metadata" => array (
                   "totalRows" => $totalrows,
                   "pageNum" => $pageNum
         return $toret;
    * constructs and executes a sql count query against the selected database
    * can take the following parameters:
    * $_REQUEST["filter"] - the filter value
    * returns : an array of the form
    * array (
    *           data => number_of_rows,
    *           metadata => array()
    function rowCount() {
         global $conn, $filter_field, $filter_type;
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //create the standard response structure
         $toret = array(
              "data" => $totalrows,
              "metadata" => array()
         return $toret;

    Hi there,
    I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
    My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
    I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
    I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
    $subscriberID = $_POST['subscriberID'];
    Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
    Any help is appreciated.
    <?php
    require_once(dirname(__FILE__) . "/2257safeDBconn.php");
    require_once(dirname(__FILE__) . "/functions.inc.php");
    require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
    * This is the main PHP file that process the HTTP parameters,
    * performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
    * and then serialize the response in an XML format.
    * XmlSerializer uses a PEAR xml parser to generate an xml response.
    * this takes a php array and generates an xml according to the following rules:
    * - the root tag name is called "response"
    * - if the current value is a hash, generate a tagname with the key value, recurse inside
    * - if the current value is an array, generated tags with the default value "row"
    * for example, we have the following array:
    * $arr = array(
    *      "data" => array(
    *           array("id_pol" => 1, "name_pol" => "name 1"),
    *           array("id_pol" => 2, "name_pol" => "name 2")
    *      "metadata" => array(
    *           "pageNum" => 1,
    *           "totalRows" => 345
    * we will get an xml of the following form
    * <?xml version="1.0" encoding="ISO-8859-1"?>
    * <response>
    *   <data>
    *     <row>
    *       <id_pol>1</id_pol>
    *       <name_pol>name 1</name_pol>
    *     </row>
    *     <row>
    *       <id_pol>2</id_pol>
    *       <name_pol>name 2</name_pol>
    *     </row>
    *   </data>
    *   <metadata>
    *     <totalRows>345</totalRows>
    *     <pageNum>1</pageNum>
    *   </metadata>
    * </response>
    * Please notice that the generated server side code does not have any
    * specific authentication mechanism in place.
    * The filter field. This is the only field that we will do filtering after.
    $filter_field = "subscriber_id";
    * we need to escape the value, so we need to know what it is
    * possible values: text, long, int, double, date, defined
    $filter_type = "text";
    * constructs and executes a sql select query against the selected database
    * can take the following parameters:
    * $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
    * $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
    * $_REQUEST["filter"] - the filter value
    * $_REQUEST["pageNum"] - the page index
    * $_REQUEST["pageSize"] - the page size (number of rows to return)
    * if neither pageNum and pageSize appear, we do a full select, no limit
    * returns : an array of the form
    * array (
    *           data => array(
    *                array('field1' => "value1", "field2" => "value2")
    *           metadata => array(
    *                "pageNum" => page_index,
    *                "totalRows" => number_of_rows
    function findAll() {
         global $conn, $filter_field, $filter_type;
          * the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
         $fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         $order = "";
         if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
              $order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //get the page number, and the page size
         $pageNum = (int)@$_REQUEST["pageNum"];
         $pageSize = (int)@$_REQUEST["pageSize"];
         //calculate the start row for the limit clause
         $start = $pageNum * $pageSize;
         //construct the query, using the where and order condition
         $query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
         //if we use pagination, add the limit clause
         if ($pageNum >= 0 && $pageSize > 0) {     
              $query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
         $recordset = mysql_query($query_recordset, $conn);
         //if we have rows in the table, loop through them and fill the array
         $toret = array();
         while ($row_recordset = mysql_fetch_assoc($recordset)) {
              array_push($toret, $row_recordset);
         //create the standard response structure
         $toret = array(
              "data" => $toret,
              "metadata" => array (
                   "totalRows" => $totalrows,
                   "pageNum" => $pageNum
         return $toret;
    * constructs and executes a sql count query against the selected database
    * can take the following parameters:
    * $_REQUEST["filter"] - the filter value
    * returns : an array of the form
    * array (
    *           data => number_of_rows,
    *           metadata => array()
    function rowCount() {
         global $conn, $filter_field, $filter_type;
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //create the standard response structure
         $toret = array(
              "data" => $totalrows,
              "metadata" => array()
         return $toret;

  • One to many to return only one row

    hi guys,
    i have an urgent problem here. i have a sql statement like below;
    SELECT ALM_SWAP2_REP.M_TP_RTMFRP0, ALM_SWAP2_REP.M_TP_RTMFRP1,
    ALM_SWAP2_REP.M_TP_RTMFRF0, ALM_SWAP2_REP.M_TP_RTMFRF1,
    To_Char(TRN_HDR_DBF.M_OPT_FLWFST,'YYYYMMDD') AS VALDATE, ALM_SWAP2_REP.M_TP_RTFXC02,
    ALM_SWAP2_REP.M_TP_RTFXC12, TRN_HDR_DBF.M_BRW_NOMU1, TRN_HDR_DBF.M_BRW_NOMU2,
    ALM_SWAP2_REP.M_TP_RTAMC02, ALM_SWAP2_REP.M_TP_RTAMC12,
    (CASE WHEN PAY_FLOW_DBF.M_LEG = 0 AND '20100831' BETWEEN To_Char(PAY_FLOW_DBF.M_CALC_DATE0,'YYYYMMDD') AND To_Char(PAY_FLOW_DBF.M_CALC_DATE1,'YYYYMMDD') THEN To_Char(PAY_FLOW_DBF.M_CALC_DATE1,'YYYYMMDD') END) AS RCV_DATE,
    (CASE WHEN PAY_FLOW_DBF.M_LEG = 1 AND '20100831' BETWEEN To_Char(PAY_FLOW_DBF.M_CALC_DATE0,'YYYYMMDD') AND To_Char(PAY_FLOW_DBF.M_CALC_DATE1,'YYYYMMDD') THEN To_Char(PAY_FLOW_DBF.M_CALC_DATE1,'YYYYMMDD') END) AS PAY_DATE
    FROM ALM_SWAP2_REP, TRN_HDR_DBF, PAY_FLOW_DBF WHERE ALM_SWAP2_REP.M_REF_DATA = 456576
    AND ALM_SWAP2_REP.M_NB = TRN_HDR_DBF.M_NB
    AND ALM_SWAP2_REP.M_NB = PAY_FLOW_DBF.M_TRN_ID
    AND ALM_SWAP2_REP.M_NB = 228128
    AND '20100831' BETWEEN To_Char(PAY_FLOW_DBF.M_CALC_DATE0,'YYYYMMDD') AND To_Char(PAY_FLOW_DBF.M_CALC_DATE1,'YYYYMMDD')
    ORDER BY ALM_SWAP2_REP.M_TRN_GRP, ALM_SWAP2_REP.M_NB
    When I join few tables, the results are returned in two rows because I have two records that in table PAY_FLOW_DBF that matches one row in table ALM_SWAP2_REP. I need these two matches but I want it to be returned in only one row without using group by. Pls help me. Thankls

    user9274041 wrote:
    i have an urgent problem here.http://www.oracle.com/html/terms.html
    >
    4. Use of Community Services
    Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
    You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle
    >
    Could you explain how something that is for your personal, informational, noncommercial purposes can be urgent?
    Or is this a violation of the terms of use and abuse of these forums?

  • How to get only matching rows in Full Outer Join

    HI All,
    I was recently asked this question.
    How to fetch only matching data from two tables using Full Outer Join. Now, I understand that this is not the objective of using Full Joins but I was wondering whether this is possible or not.
    Any help in this regard will be highly appreciated.

    Full outer join returns both matching and not matching rows, if you want only matching rows why you don't use INNER JOIN?
    The following query does an INNER JOIN using a FULL JOIN which I think it doesn't make any sense.
    SELECT *
    FROM
    A FULL OUTER JOIN B
    ON A.ColumnName = B.ColumnName
    WHERE
    A.ColumnName IS NOT NULL
    AND B.ColumnName IS NOT NULL
    EntityLite: A Lightweight, Database First, Micro ORM

  • Power Query occassionally connects, seems to load, but returns only 200 rows with 1 error

    I have a Power Query that i have used for few weeks, successfully, but occasionally requires being run a few times to return records.  Just lately it seems to require run more than a few times to make it work. 
    When it doesn't return records , it seems to connects and start retrieving data, but returns only randomly like 100 - 200 rows with 1 error.  The error doesn't have any message. So its hard to troubleshoot from that perspective.
    Query appends two other large and merges in a few others. The data sources are either csv files, Sharepoint Lists and tables in workbook.
    I haven't identified anything in terms of environment or query changes that might cause this.
    When it finally does retrieve all records,  it might be after i have done the following things, but i can't say for certain exactly what did the trick:
    * to run query multiple times
    *maybe simply changing anything in query resolves issue
    * making upstream queries (that are merged or appended into this query)  to Not Load to worksheet or model, eg just have connection
    I'd think this type of error and situation while not common is encountered by others.
    Does this ring a bell for anyone, and if so, can you please shed some light on the reasons and resolutions for this?
    Thanks!

    If you click on "1 error" it should show the editor with a query that will select the rows with errors. This unfortunately might not show all errors for various reasons, but you should try it.
    If that doesn't work, here's an example of how to retrieve error details.
    Suppose the following query:
    = Table.FromRecords({[A="B", B="C" + 1]})
    Notice how we're using the + operator with a string and number. This will result in an error.
    I can create a custom column that uses the 'try' operator over the B column. This returns a record with details which I then expand to retrieve the message.
    let
    Source = Table.FromRecords({[A="B", B="C" + 1]}),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each try [B]),
    #"Expand Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"HasError", "Error"}, {"Custom.HasError", "Custom.Error"}),
    #"Expand Custom.Error" = Table.ExpandRecordColumn(#"Expand Custom", "Custom.Error", {"Message"}, {"Custom.Error.Message"})
    in
    #"Expand Custom.Error"
    Let me know how this works for you.
    Tristan

  • Select from Oracle to MySQL returns only one row

    Environment:
    The Oracle Developer Days Virtual Box image, so that's 11gR2 EE on OEL
    MySQL 5.1.51-community
    mysql-connector-odbc-5.1.7-0.i386.rpm
    unixODBC 2.3.0
    I got the connection working, I can insert, update and delete records in the MySQL DB from Oracle (SQL Plus).
    But when I enter select * from "employees"@mysql I only get the first record returned.
    If I enter select * from "employees"@mysql order by "id" desc, I only get the last one...
    If I enter select count(*) from "employees"@mysql, I get the - correct - result of 3.
    So, how do I get the complete set of (all) records from a MySQL table in Oracle? Is there some kind of setting or is this intended behavior and do I have to create a PL/SQL loop and put the results into a collection or something like that?

    I've create a table like yours:
    create table gateway.employees(id int(10) auto_increment,
    first_name varchar(30),
    last_name varchar(100),
    personal_code varchar(20),
    birthday date,
    salary decimal(10,2),
    is_active int(1),
    PRIMARY KEY (id));
    insert into gateway.employees (first_name,last_name) values ('Name 1', 'Name 1');
    insert into gateway.employees (first_name,last_name) values ('Name 2', 'Name 2');
    insert into gateway.employees (first_name,last_name) values ('Name 3', 'Name 3');
    insert into gateway.employees (first_name,last_name) values ('Name 4', 'Name 4');
    insert into gateway.employees (first_name,last_name) values ('Name 5', 'Name 5');
    select * from gateway.employees;
    and tested it using DataDirect and MySQL ODBC.
    The DataDirect shows all 5 lines whereas MySQL 5.1.0.7 ODBC shows only 1 row.
    (isql isn't using extended fetching like DG4ODBC does).
    Edited by: kgronau on Nov 4, 2010 4:03 PM
    Here the result (fetching ID column):
    MySQl ODBC;
    SQL> select "id" from "employees"@MYSQL_EMGTW_1121_DB;
    id
    1
    DD ODBC V6:
    SQL> select "id" from "employees"@DD60_MYSQL_EMGTW_1121_DB;
    id
    1
    2
    3
    4
    5
    Edited by: kgronau on Nov 4, 2010 4:33 PM
    The 32bit version of MySQL ODBC (5.1.5 - no 5.1.7 release yet installed) works also:
    SQL> select "id" from "employees"@MYSQL_32;
    id
    1
    2
    3
    4
    5
    => so it is an ODBC issue

  • How to return the entire row from a table

    Hi guys,
    Tabl A
    FirstName varchar2(10),
    Age Number,
    Add varchar2(100),
    Table B
    Filedname varchar2(200), -- contains all the fields of table A
    Datatype varchar2(100), -- Contains the datatypes of the filedname
    Length Number -- contains the length of the fileds
    Now how can i return the entire row from table A with the datatype and its length.
    Any help would be appreciated ?
    Here is the query I wrote but it how to take the datatype and its length..
    create or replace procedure disp_table_data
    as
    type r_cursor is REF CURSOR;
    c_A r_cursor;
    er A%rowtype;
    begin
    open c_A for select * from A;
    loop
    fetch c_A into er;
    exit when c_A%notfound;
    dbms_output.put_line(er.FirstName||'--'||er.Age);
    end loop;
    close c_A;
    END;
    /

    Guys,
    I want column value from table A and its corresponding data_type and length from table B. I think I cant do it through joins.
    Any idea would be appreciated ?.
    Example ..
    Tabl A
    FirstName varchar2(10),
    Age Number,
    Add varchar2(100)
    insert into A values('John',24,'Boston');
    Table B
    Filedname varchar2(200), -- contains all the fields of table A
    Datatype varchar2(100), -- Contains the datatypes of the filedname
    Length Number -- contains the length of the fileds
    insert into B values('FirstName','varchar2',10); -- this is coming from table A.
    Output should be like this...
    John,Varchar2,10
    Here (John is the FirstName - coming from table A, Varchar2 is a Datatype and 10 is the Length which are coming from table B ). Only column values are coming from table A , corresponding datatype and length are coming from B.
    Any idea would be appreciated ?
    Thanks.

  • Problem to calculate the coherence (using NetworkFunction-VI) with only 1 row of data for each, the stimulus and response input

    Hello,
    I am trying to calculate the coherence of a stimulus and response
    signal using the Network Functions (avg) VI's. The problem is that I
    always get a coherence of "1" at all frequencies. This problem is
    already known (see KnowledgeBase document: Why is the Network Functions (avg) VI's Coherence Function Output "1"?).
    My trouble is that the described solution (-> the stimulus and response input matrices need to have at least two rows to get non-unity coherence values) doesn't help me much, because I only have one array of stimulus data and one array of response values.
    Thus, how can I fullfil the 'coherence-criteria' to input at least two rows of data each when I just have one row of data each?
    Any hint or idea is very much appreciated. Thanks!
    Horst

    With this weird board layout, I'm not sure whether you were asking me, but, on the assumption that you were, here goes:
    I found no need to use the cross-power spectrum and power spectrum blocks
    1... I was looking for speed.
    2... I already had the component spectral data there, for other purposes. From that, it's nothing but addition and multiplication.
    3... The "easy" VIs, assume a time wave input, as I recall. Which means they would take the same spectrum of the same timewave several times, where I only do it once.
    I have attached PNGs of my code.
    The PROCESS CHANNEL vi accepts the time wave and:
    1... Removes DC value.
    2... Integrates (optional, used for certain sensors).
    3... Windows (Hanning, etc. - optional)
    4... Finds spectrum.
    5... Removes spectral mirrors.
    6... Scales into Eng. units.
    7... From there, you COULD use COMPLEX-TO-POLAR, but I don't care about the phase data, and I need the MAG^2 data anyway, so I rolled my own COMPLEX-TO-MAG code.
    The above is done on each channel. The PROCESS DATA vi calls the above with data for each channel. The 1st channel in the list is required to be the reference (stimulus) channel.
    After looping over each channel, we have the Sxx, Syy, and Sxy terms. This code contains some averaging and peak-picking stuff that's not relevant.
    From there, it's straightforward to ger XFER = Sxy/Sxx and COHERENCE = |Sxy|^2 / (Sxx * Syy)
    Note that it uses the MAGNITUDE SQUARED of Sxy. Again, if you use the "easy" stuff, it will do a square-root operation that you just have to reverse - it is obtained faster by the sum of the squares of the real and imag parts.
    Hope this helps.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    ProcessChannel.png ‏25 KB

  • XMLTABLE returns only first row

    I have follwoing XML inserted into the column named as TEXT in the table MASTERTB.
    *<?xml version="1.0" encoding="utf-8" ?>*
    *<Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">*
    *<Rowset>*
    *<Columns>*
    *<Column Description="Material Number" MaxRange="1" MinRange="0" Name="MATERIAL" SQLDataType="1" SourceColumn="MATERIAL"/>*
    *<Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>*
    *</Columns>*
    *<Row>*
    *<MATERIAL>1000000144</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>2000000008</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>2000000009</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>2000000016</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>3000000036</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *</Rowset>*
    *</Rowsets>*
    Now, when my requirement is to get all the Material values so when I run follwoing query in Oracle,
    SELECT RW.MATERIAL
    FROM MASTERTB TM,
    XMLTable('//Row' PASSING TM.TEXT
    COLUMNS  "MATERIAL"    CHAR(30) PATH 'MATERIAL') AS RW
    it return only 1000000144 (First MATERIAL). How can I read all the MATERIAL? Also, how can I read the entire XML in Text format if I want to check what has been inserted?
    ANy help will be appreciated !
    Edited by: 967327 on Oct 27, 2012 12:28 AM

    >
    <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
    <Rowset>
    </Rowset>
    >
    so where is </Rowsets> ?
    your query works for me
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    SQL>
    SQL> with MASTERTB as
      2  (select
      3  xmltype('<?xml version="1.0" encoding="utf-8" ?>
      4  <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
      5  <Rowset>
      6  <Columns>
      7  <Column Description="Material Number" MaxRange="1" MinRange="0" Name="MATERIAL" SQLDataType="1" SourceColumn="MATERIAL"/>
      8  <Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>
      9  </Columns>
    10  <Row>
    11  <MATERIAL>1000000144</MATERIAL>
    12  <TANK>T1000</TANK>
    13  </Row>
    14  <Row>
    15  <MATERIAL>2000000008</MATERIAL>
    16  <TANK>T1000</TANK>
    17  </Row>
    18  <Row>
    19  <MATERIAL>2000000009</MATERIAL>
    20  <TANK>T1000</TANK>
    21  </Row>
    22  <Row>
    23  <MATERIAL>2000000016</MATERIAL>
    24  <TANK>T1000</TANK>
    25  </Row>
    26  <Row>
    27  <MATERIAL>3000000036</MATERIAL>
    28  <TANK>T1000</TANK>
    29  </Row>
    30  </Rowset></Rowsets>') TEXT from dual)
    31  SELECT RW.MATERIAL
    32  FROM MASTERTB TM,
    33  XMLTable('//Row' PASSING TM.TEXT
    34  COLUMNS "MATERIAL" CHAR(30) PATH 'MATERIAL') AS RW
    35  /
    MATERIAL
    1000000144
    2000000008
    2000000009
    2000000016
    3000000036
    SQL>
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    SQL>
    SQL> with MASTERTB as
      2  (select
      3  xmltype('<?xml version="1.0" encoding="utf-8" ?>
      4  <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
      5  <Rowset>
      6  <Columns>
      7  <Column Description="Material Number" MaxRange="1" MinRange="0" Name="MATERIAL" SQLDataType="1" SourceColumn="MATERIAL"/>
      8  <Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>
      9  </Columns>
    10  <Row>
    11  <MATERIAL>1000000144</MATERIAL>
    12  <TANK>T1000</TANK>
    13  </Row>
    14  <Row>
    15  <MATERIAL>2000000008</MATERIAL>
    16  <TANK>T1000</TANK>
    17  </Row>
    18  <Row>
    19  <MATERIAL>2000000009</MATERIAL>
    20  <TANK>T1000</TANK>
    21  </Row>
    22  <Row>
    23  <MATERIAL>2000000016</MATERIAL>
    24  <TANK>T1000</TANK>
    25  </Row>
    26  <Row>
    27  <MATERIAL>3000000036</MATERIAL>
    28  <TANK>T1000</TANK>
    29  </Row>
    30  </Rowset></Rowsets>') TEXT from dual)
    31  SELECT RW.MATERIAL
    32  FROM MASTERTB TM,
    33  XMLTable('//Row' PASSING TM.TEXT
    34  COLUMNS "MATERIAL" CHAR(30) PATH 'MATERIAL') AS RW
    35  /
    MATERIAL
    1000000144
    2000000008
    2000000009
    2000000016
    3000000036
    SQL> try
    31  SELECT RW.MATERIAL
    32  FROM MASTERTB TM,
    33  XMLTable('Rowsets/Rowset/Row' PASSING TM.TEXT
    34  COLUMNS "MATERIAL" varchar2(30) PATH 'MATERIAL') AS RW
    35  /
    MATERIAL
    1000000144
    2000000008
    2000000009
    2000000016
    3000000036
    SQL>

  • How to return only the first string

    Hi Guys,
    I have a mapping where I am creating a filename from data in within my data file, I am using one of my variables i.e. Account
    The data looks like this
    Account:
    123
    123
    123
    456
    456
    456
    789
    789
    789
    What I want is to is return only the first row u201C123" and concatenate it with a constant to make up the filename.
    Any help will be appreciated.
    Kind Regards,
    CJ Bester

    very simple
    use copy value standard function like below.
    Account------->copyvalue(0)----------->
                                                                      CONCAT------------->TARGET
                                         Constant------->
    Regards,
    Raj

  • How I show only 20 rows per pages in a rtf report in BI Publisher 11g

    I'm making a report and i want show only 20 rows per pages in a formatt RTF. I get this with anything as a xls, xslt....
    I'm a new user....please . Any idea..???
    Thank for all.
    Edited by: 844565 on Mar 15, 2011 7:34 AM

    Instead of doing that take the url CURRENT_SERVER_URL(pre-definde BI Publsiher variable) by declaring like below
    <?param@begin:CURRENT_SERVER_URL?>
    Then subsequently add the extra patameters eg. region like below
    {$CURRENT_SERVER_URL}Data/Country.xdo&p_region={REGION} <- get this REGION value from XML
    Cheers,
    ND
    Use the "helpful" or "correct" buttons to award points to replies.

Maybe you are looking for

  • Minor c3-00 glitch - when moving an item in the me...

    Items in the main menu are sorted in different order when viewed in List view and in Grid view. This leads to confusion when sorting in list view or in grid view. When I move an item in the menu in list view, then change back to grid view, the items

  • Using OD as a simple contact list for mail

    Hello, A probably stupid question but ... : is it possible to add, in Open Directory, informations like e-mail or mobile phone number WITHOUT creating an account in Open Directory ? This is what i'm trying to do : we have an OS X server with Open Dir

  • BT Billing Confusion

    I spent ages on the phone today and eventually got through to BT. I had been happily paying my monthly bill without a care until recently. I'm out of work so I've been doing a budget and reviewing my spending. Anyway, I'm on: Unlimited Broadband whic

  • Icon Change Problem

    I wanted to change the icon for my computer, but the info window says I am "read only" with no options below. How do I do this and why, if I am the admin., is it read only? Thanks

  • Input stream

    Can datainputstream be used to read and write a file? I tried to save a file from a URL. But the file isn't read completely. What is my mistake?      HttpConnection c = (HttpConnection) Connector.open(url); //change here while run      DataInputStrea