Query assistance

I need help adding the Delivery table (ODLN) to a query from another thread.  Here is the query...
Select s.ItemCode,s.IntrSerial,
p.DocNum,p.CardName,p.DocDate,
i.DocNum,i.CardName,i.DocDate
From OSRI s
left outer join SRI1 tp on tp.SysSerial=s.SysSerial and tp.BaseType=18
left outer join OPCH p on p.DocEntry=tp.BaseEntry
left outer join SRI1 td on td.SysSerial=s.SysSerial and td.BaseType=13
left outer join OINV i on i.DocEntry=td.BaseEntry
Where (p.DocDate between '[%0]' and '[%1]' or  p.DocDate is null)
    and (i.DocDate between '[%0]' and '[%1]'  or i.DocDate is null)
    and s.ItemCode='[%2]'
The query is from this thread
A/P Invoice Number With A/R Invoice Number
If it helps any its not necessary for my purposes to have the OPCH table, so if it makes the query easier to build you can leave it out.
Thanks

Hi,
Please let us know the exact requirement from the table ODLN table.
Check the following query with the ODLN table included :
Select s.ItemCode,s.IntrSerial,
p.DocNum,p.CardName,p.DocDate,
i.DocNum,i.CardName,i.DocDate
From OSRI s
left outer join SRI1 tp on tp.SysSerial=s.SysSerial and tp.BaseType=18
left outer join OPCH p on p.DocEntry=tp.BaseEntry
left outer join SRI1 td on td.SysSerial=s.SysSerial and td.BaseType=13
left outer join OINV i on i.DocEntry=td.BaseEntry
left outer join ODLN j on j.CardName = td.CardName
Where (p.DocDate between [%0] and [%1] or p.DocDate is null)
and (i.DocDate between [%0] and [%1] or i.DocDate is null)
and s.ItemCode=[%2]
Kind Regards,
Jitin
SAP Business One Forum Team

Similar Messages

  • Outgoing payment query assistance.

    Hi experts,
    Can you please assist me with a query that addresses my request.
    My request is, during the outgoing payment process in the payment means we choose a G/L account.
    I want the query to show the G/L account code and it's corresponding name whether check or cash or bank transfer.
    Please this query is urgent and I need help.
    Regards
    Justice

    Hi Justice,
    I am not able to Understand Correct Requirement but Please check below Query which will give you All Modes of Account and Account Name. Please check below
    SELECT T0.[DocNum], T0.[DocDate], T1.[CheckAct] AS Check_Account, T2.[AcctName] AS Check_Account_Name, T0.[CashAcct] AS Cash_Account, T3.[AcctName] AS Cash_Account_Name, T0.[TrsfrAcct] AS Transfer_Account, T4.[AcctName] AS Transfer_Account_Name FROM OVPM T0  LEFT JOIN VPM1 T1 ON T0.[DocEntry] = T1.[DocNum] LEFT JOIN OACT T2 ON T1.[CheckAct] = T2.[AcctCode] LEFT JOIN OACT T3 ON T0.[CashAcct] = T3.[AcctCode] LEFT JOIN OACT T4 ON T0.[TrsfrAcct] = T4.[AcctCode]
    Hope this help
    Regards:::::
    Atul Chakraborty

  • Shell Query assistance please

    Hey guys and gals,
    I'm new here and would like some assistance.  I work for a company as an entry level support tech.  I create emails and update distribution lists ect..  I'm by no means an exchange guru.  We have a client that likes to have his employees
    emails forwarded to him.  But now he wants to know who is forwarded to him now.  I have no clue how to find this out.  So i did some research and i came up with the shell script
    Get-Mailbox | Where {$_.ForwardingAddress -like John} | Select Name, ForwardingAddress, DeliverToMailboxAndForward
    Of course it doesn't come back with anyhting.  I'm assuming i've got the syntax wrong.  
    Can any of you lend some help please.  I've been researching for the past week and can't seem to figure out why that isn't working.  (i've tried ", (), %, '.  I'm assuming it's the -like portion of the query.

    Hello,
    You need to give * around the name to get the result...
    So try this...
    Get-Mailbox -ResultSize Unlimited | Where {$_.ForwardingAddress -like "*John*"} | Select Name, ForwardingAddress, DeliverToMailboxAndForward

  • Query Assistance Needed - Please

    Monthly Training Table
    >> monthly_training.record_id (int)
    >> , monthly_training.trng_year (int)
    >> , monthly_training.trng_month (int)
    >> , monthly_training.trng_title (varchar)
    >> , monthly_training.trng_code (varchar)
    >> , monthly_training.trng_narrative (longtext)
    Training Completed Table
    >> training_completed.record_id (int)
    >> , training_completed.recorded_by (varchar)
    >> , training_completed.emp_id (varchar)
    >> , training_completed.trng_year (int)
    >> , training_completed.trng_quarter (int)
    >> , training_completed.trng_month (int)
    >> , training_completed.trng_date (date)
    >> , training_completed.trng_category (varchar)
    >> , training_completed.trng_sub_category (varchar)
    >> , training_completed.trng_code (varchar)
    >> , training_completed.trng_start_time (time)
    >> , training_completed.trng_stop_time (time)
    >> , training_completed.trng_hours (decimal)
    DB = MySQL -- CF8
    emp_id = B1200 < stored in cookie at login
    Scenario –
    Monthly Training Table - contains scheduled training for an
    entire year. This training is displayed on a page per the month the
    training should be completed in.
    Training Completed Table – contains the information of
    what training was completed per individual.
    Task At Hand – I would like to display the monthly
    scheduled training for the current year and cross reference the
    completed training table and if the individual has completed the
    training further display something next to the training title, to
    signify completed.
    Example:
    Computer Training – Outlook
    * Off. Dev. – Emergency Scene Safety
    Fire Suppression – Salvage
    I have tried many methods of querying this but have not been
    able to achieve the goal. Perhaps I am making this harder than it
    needs to be. Hopefully someone in the forum can shed some light on
    what I should be doing. Assistance would be greatly appreciated.
    Leonard

    yes, i see it now - the WHERE clause makes sure only
    completed training
    of that employee are selected... my bad - i should have
    changed that
    after you told me that emp_id field was in tc table, not
    mt...
    ok, here we go... this will be a little more complicated...
    try this beast:
    <cfquery name="rs_trng_ck" datasource="#datasource#">
    SELECT mt.trng_title, mt.trng_month, mt.trng_code,
    tcsq.completed
    FROM monthly_training mt
    LEFT JOIN
    (SELECT tc.trng_code AS completed
    FROM training_completed tc
    WHERE tc.emp_id = <cfqueryparam cfsqltype="cf_sql_varchar"
    value="#emp_id#">) AS tcsq
    ON
    mt.trng_code = tcsq.completed
    WHERE mt.trng_year = YEAR(NOW())
    ORDER BY mt.trng_month, mt.trng_title
    </cfquery>
    basically, what this does is uses a sub-query in the FROM
    clause to
    pre-select only those records from tc table where emp_id
    field equals
    the #emp_id# value, and only then left-joins the mt table to
    this
    sub-query recordset, which should result in ALL records from
    mt table
    and only those from tc table where emp_id is correct
    the <cfoutput ...> part shoudl stay the same as before.
    hope this one works :)
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • SQL Query Assistance Required for Full Outer Join

    Hi,
    Lets say I have two tables, i.e:
    TAB_A (colA1, colA2, colA3, colA4)
    TAB_B (colB1, colB2, colB3, colB4) where colB2 is a FK to colA1
    I am after an SQL query that will cater for both the following two scenarios.
    Scenario 1:
    TAB_A has two rows of data, i.e
    (1, ABC100, 1, WG_A)
    (2, ABC100, 2, WG_B)
    TAB_B has one row of data, i.e
    (1, 1, EMP_222, 4)
    I use the following SQL:
    select a.*, b.*
    from tab_a a FULL OUTER JOIN tab_b b ON (a.colA1 = b.colB2)
    where a.colA2 = 'ABC100'
    This returns two rows:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    2, ABC100, 2, WG_B
    Now, what I actually would like my query to do is actually only return the row where a tab_b record exists, i.e, should only return one record:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    This I can achieve by using a RIGHT OUTER JOIN instead above, but this causes issue with my scenario 2, which is the following set-up
    Scenario 2:
    TAB_A has only one row of data this time, i.e
    (2, ABC100, 2, WG_B)
    TAB_B has no data at all this time
    This returns no rows but I actually now want this single record from tab_a returned.
    I basically require an SQL query that will cater for both the top 2 scenarios, i.e, if a tab_b record exists from the outer join then only return this record along with tab_a data. If a tab_b record doesn't exist, then only return the tab_a record.
    Hope the above makes sense.
    Thanks.

    Is it what you need (not very elegant) ?
    SQL> select * from t_outer;
            ID CODE
             1 100
             2 100
    SQL> select * from t_inner;
    no rows selected
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             1 100
             2 100
    SQL> insert into t_inner values(2);
    1 row created.
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             2 100                 2
    Rgds.

  • SAP B1 Query - assistance needed

    Dear Experts,
    We are working on cash flow forecasting model, i.e going forward 12 months, which in written in MS Excel. We update it with actual data recorded in SAP B1 (Ver 8.8 PL18)  A manual process.
    Was wondering if we can get a single query written which will provide the following data:
    Sales and Purchases by BP in a given time (user specified)
    BP Code
    BP Name
    Type of Document (i.e invoice. credit memo)
    Date of the document
    The value of the document (Gross including any taxes)
    Collections and Payments of to/from BP in a given time (user specified)
    BP Code
    BP Name
    Document Type (i.e receipt or payment)
    Document number the reciept or payment is related to to i.e the invoice that is being paid or receipted
    Date pf payment/receipt
    Amount
    Thank you in advance.
    Regards
    Raj

    Hi,
    Try this:
    SELECT distinct T0.[CardCode], T0.[CardName], T0.[DocNum] as Invoice#, T0.[DocDate], T0.[DocTotal], T3.[DocNum] as Credit#, T3.[DocDate], T3.[DocTotal] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry left join  RIN1 T2 on  T2.[BaseEntry]  = t0.docentry and  T2.[BaseLine]  =  T1.[LineNum] left JOIN ORIN T3 ON T2.DocEntry = T3.DocEntry WHERE T0.[DocDate] between [%0] and [%1]
    2. It is not possible to get invoices in single query.
    Advice, your sales and purchase process to understand and write query.
    Thanks & Regards,
    Nagarajan

  • BO 6.5.1 Query Assistance

    Hey there.  I hope I am in the right place. 
    I am trying to design a query in the BO Query Panel and I am having an issue.  I am placing a field in the "Result Objects" location (for this issue, let's say it's "Field1") and my criteria in the conditions location.  However, my query will not return any results in which "Field1" is null. 
    I know there are null records for this field.  It will only return records that this field is populated. 
    Any ideas on how I can fix this?
    Thanks!
    tp

    Hi Tom,
    Do you get any error message?
    Normally, when there is no data to return, you should get the message "No data to fetch".
    Please perform the following test:  
    - Place the object <Field 1> in the Results Objects and click on Run.  Do not put anything in Conditions.
    What do you get?
    Please check/provide the following details:
    - Do you have this issue with any object/universe or it's a specific one?
    - make sure you set the defined and assigned the connection to the universe in Designer
    Can you test with our demo universe and see if you get the same behaviour?
    Regards,
    Jeff

  • Lync LcsLog SQL query assistance

    I have this SQL query that we used in the past on LCS and OCS which worked fine.  For Lync it's returning the info I want, but it's also returning all kinds of HTML characters.
    SQL query
    select * from LcsLog.dbo.Messages,LcsLog.dbo.Users where LcsLog.dbo.Users.UserId=Messages.ToId and LcsLog.dbo.Users.UserUri='[email protected]'
    Here's what it returns.  As you can see, all this was just me saying "hello".  How can I remove the html?
    2011-06-04 14:03:19.057    1    2011-06-04 14:03:19.057    1    5    2    2    1    {\rtf1\ansi\ansicpg1252\fromhtml1 \fbidis \deff0{\fonttbl 
    {\f0\fswiss Arial;}  {\f1\fmodern Courier New;}  {\f2\fnil\fcharset2 Symbol;}  {\f3\fmodern\fcharset0 Courier New;}  {\f4\fswiss MS Shell Dlg 2;}}  {\colortbl\red0\green0\blue0;\red0\green0\blue255;\red0\green0\blue0;}  \uc1\pard\plain\deftab360
    \f0\fs24   {\*\htmltag0 \par }  {\*\htmltag48 <BODY>}{\*\htmltag64}\htmlrtf {\htmlrtf0   {\*\htmltag148 <FONT color=#000000 size=2 face="MS Shell Dlg 2">}\htmlrtf {\cf2 \fs20 \f4 \htmlrtf0   {\*\htmltag4 \par
    }\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf}\htmlrtf0    {\*\htmltag96 <DIV dir=ltr>}\htmlrtf {\ltrpar\ltrch\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 \htmlrtf {\cf2 \fs20 \f4 \htmlrtf0
    hello\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0    {\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0   {\*\htmltag248 </FONT>}  {\*\htmltag58 </BODY>}}   
    0    0    0    NULL    NULL    2011-06-17 20:04:42.227    2    [email protected]    0    0
    d

    We are a Microsoft ISV and we have spent a great deal of time reviewing and diving into the lcslog.  In order to help many of our larger enterprise customers, we have built an application specifically to help search, view, and share the conversations
    in the LCSLog database. 
    Of course, you can extract and assemble this content yourself - but you might want to give us a look.  It's possible it that is might save you some time (on the dev front)
    We have a free eval and support both Lync 2010 and Lync 2013 - with a pretty great UI, great performance, and some visual drill down.
    Might save you some time...
    http://www.tryhrauditor.com/
    Peyton

  • UCCX SQL query assistance needed.

    Hello,
    I am working on a SQL query that does a lookup of the calling number and the last four digits entered by the customer.  If I hard code the lastFourGC variable I am able to return a successful result.  If I use $lastFourGC I get the following error.
    $callingNumber  - Is exactly that, the calling number.
    $lastFourGC - Is the last four digits collected from the customer.
    SELECT * FROM GiftCardFulfillment WHERE Phone=$callingNumber and Right (GiftCard16DigitNumber, 4)=$lastFourGC

    Tanner,
    I had tried that with single and double quotes and it didn't work.  I did end up getting it to work by rearranging the order.  I'm not sure why that worked, but this is what the query looks like now and it works.
    SELECT * FROM [leads].[dbo].[GiftCardFulfillment]   
             WHERE Right (GiftCard16DigitNumber, 4)=$lastFourGC and Phone=$callingNumber

  • SELECT query Assistance

    The datastructure for this set-up is 2 tables.  One holds the actual data, one holds the field names.  So for example, tableName holds the fields, employeeFirstName, employeeLastName, employeeStore, and tableAnswers would hold, Bob, Godfrey, Vicksburg
    tableName
    EntryID
    employeeFirstName varchar(500),
    employeeLastName varchar(500),
    employeeStore varchar(500)
    tableAnswer
    EntryID
    Answer nvarchar(2000)
    I link on Entry ID to return the data for each entry, but that is only based off one entry, what if I wanted ALL records where
    Answer was a specific city, how could I write that query to give me that info?

    The datastructure for this set-up is 2 tables.  One holds the actual data, one holds the field names.  So for example, tableName holds the fields, employeeFirstName, employeeLastName, employeeStore, and tableAnswers would hold, Bob, Godfrey, Vicksburg
    tableName
    EntryID
    employeeFirstName varchar(500),
    employeeLastName varchar(500),
    employeeStore varchar(500)
    tableAnswer
    EntryID
    Answer nvarchar(2000)
    I link on Entry ID to return the data for each entry, but that is only based off one entry, what if I wanted ALL records where
    Answer was a specific city, how could I write that query to give me that info?
    If I am understanding your needs/data structure correctly try something like this.  A query with a sub-query
    SELECT a.employeeFirstName, a.employeeLastName, a.emploeestore, b.Answer
    FROM tableName a
    INNER JOIN tableAnswer b
    ON a.Entryid = b.Entry_id
    WHERE b.Answer IN (
    SELECT DISTINCT(b.EntryID)
    FROM tableName a
    INNER JOIN tableAnswer b
    ON a.Entryid = b.Entry_id
    WHERE b.Answer IN ('Vicksburg')

  • UPDATE Query Assistance

    Hi there
    I need assistance in rectifying the UPDATE SQL below. PENS_BAK table is required to be updated with the first row in the group of PO_NO of PENS_DTL.
    UPDATE PENS_BAK SET COMM = (SELECT COMM FROM (
    SELECT PO_NO, PENS_FROM, COMM , ROW_NUMBER() OVER (PARTITION BY PO_NO ORDER BY PENS_FROM ) SRNO
    FROM PENS_DTL WHERE COMM > 0 ) WHERE PO_NO = PENS_BAK.PO_NO AND SRNO = 1) Kindly help me out
    Thanks

    UPDATE PENS_BAK
      SET COMM = (SELECT COMM FROM (
                                    SELECT PO_NO,
                                          PENS_FROM,
                                          COMM ,
                                          ROW_NUMBER() OVER (PARTITION BY PO_NO ORDER BY PENS_FROM ) SRNO
                                    FROM PENS_DTL WHERE COMM > 0 )
                                      WHERE SRNO = 1)That should work right?
    Isn't that working?

  • Query Assistance - Calculating percentage

    Greetings,
    I may just be looking at this for way to long and not seeing the proper coding/syntax
    required to accomplish what it is I am trying.
    I have one query to figure out an overall count for each organization in a database. I
    then have a second query to figure out the success rate count to compare to the
    overall count per organization. I am running the second query inside the <cfoutput>
    of the first query to achieve the desired count/display intended.
    The overall and the success counts are displaying as I intend them to. However, I
    am unable to get the percentage part to work. Perhaps someone can look at my
    code and layout to see where it is I am failing. I have provided the desired look and
    my code below for review.
    I am certainly open to suggestions on how to do it differently / better, should someone
    have an insight on how to accomplish my desired outcome.
    CF = CF8
    DB = MySQL
    Thanks in advance
    Leonard B
    ===== Desired Look =====
    Total Attempts
    First Attempts
    Percent
    Organization Name
    20
    18
    Org. Name
    40
    33
    Org. Name
    51
    44
    Org. Name
    ===== Code Below =====
    <cfquery name="rs_attempts" datasource="DSN">
    SELECT
    Count(airway_management.agency_cert_number) AS agency_count,
    airway_management.agency_cert_number,
    airway_management.year_of_call,
    airway_management.et_attempts,
    airway_management.et_attempts_successful,
    airway_management.dept_org
    FROM
    airway_management
    WHERE
    airway_management.year_of_call = <cfqueryparam cfsqltype="cf_sql_integer" value="2009">
    GROUP BY
    airway_management.dept_org
    </cfquery>
    <table width="0" border="1" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
        <td><div style="font-family: Arial; font-size: 13px">Total Attempts</div></td>
        <td><div style="font-family: Arial; font-size: 13px">First Attempts</div></td>
        <td><div style="font-family: Arial; font-size: 13px">Percent</div></td>
        <td><div style="font-family: Arial; font-size: 13px">Organization Name</div></td>
    </tr>
    <cfoutput query="rs_attempts">
    <tr>
        <td><div style="font-family: Arial; font-size: 13px">#agency_count#</div></td>
            <cfquery name="rs_1_attempts" datasource="DSN">
            SELECT
            agency_cert_number,
            dept_org,
            year_of_call,
            et_attempts,
            et_attempts_successful
            FROM
            airway_management
            WHERE
            year_of_call = <cfqueryparam cfsqltype="cf_sql_integer" value="2009"> AND
            agency_cert_number = <cfqueryparam cfsqltype="cf_sql_varchar" value="#rs_attempts.agency_cert_number#"> AND
            et_attempts = <cfqueryparam cfsqltype="cf_sql_integer" value="1"> AND
            et_attempts_successful = <cfqueryparam cfsqltype="cf_sql_varchar" value="Yes">
            </cfquery>   
            <cfset percent = ((#rs_attempts.recordcount# - #rs_1_attempts.recordcount#)*100)>
        <td><div style="font-family: Arial; font-size: 13px">#rs_1_attempts.recordcount#</div></td>
        <td><div style="font-family: Arial; font-size: 13px">#NumberFormat(percent,999.00)#</div></td>
        <td><div style="font-family: Arial; font-size: 13px">#dept_org#</div></td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    Try replacing this line
    <cfset percent = ((#rs_attempts.recordcount# - #rs_1_attempts.recordcount#)*100)>
    with
    <cfset percent = #(rs_attempts.recordcount - rs_1_attempts.recordcount)*100#>
    Not sure on the brackets though - if not try
    <cfset percentWorking= #rs_attempts.recordcount - rs_1_attempts.recordcount#>
    <cfset percent = #working * 100#>
    Mi-ul

  • Query assistance - Based on CurrentDate

    Hi,
    I need to create a query for a daily alert. I need the result to list customer records that have the UDF value (number) match the today's date.
    Ex. if today is May 4, it would list all customers with invoice date of 4 (UDF value). Below is what I had started but stumped on what the correct syntax is for CurrentDate (that doesn't seem to work).
    Thank you,
    Heather
    Started query:
    SELECT T0.CardCode, T0.CardName as 'Customer Name', T0.U_InvDt, T0.U_SignAct
    FROM OCRD T0
    WHERE  T0.U_InvDt = ....??

    Hi,
    Is this UDF value number 4 or May 4? Suppose it is the later, you can try:
    SELECT T0.CardCode, T0.CardName as 'Customer Name', T0.U_InvDt, T0.U_SignAct
    FROM OCRD T0
    WHERE DateDiff(DD,T0.U_InvDt,GetDate())=0
    Thanks,
    Gordon

  • Query assistance needed

    Hi experts,
    I am trying below query to find out all columns which are present more than once i.e which are all common in tables.
    select a.column_name,b.table_name from
    (select column_name, count(*) from sys.all_tab_columns
    group by column_name
    having count(*)>1) a, sys.all_tab_columns b
    where
    a.column_name=b.column_name
    and owner = 'CP'
    order by a.column_name i am getting results.. but i require result something like below:
    column_name    Table_name
    col1           Table1   
                   Table2
    col2           Table1
                   Table4
    col3           Table1
                   Table2
                   Table4Regards
    asp

    select  case row_number() over(partition by a.column_name order by b.table_name)
              when 1 then a.column_name
            end column_name,
            b.table_name
      from (
            select  column_name,
                    count(*)
              from  sys.all_tab_columns
              group by column_name
              having count(*)>1
           ) a,
           sys.all_tab_columns b
      where a.column_name=b.column_name
        and owner = 'CP'
      order by a.column_name,
               b.table_name
    /For example:
    SQL> select  case row_number() over(partition by a.column_name order by b.table_name)
      2            when 1 then a.column_name
      3          end column_name,
      4          b.table_name
      5    from (
      6          select  column_name,
      7                  count(*)
      8            from  sys.all_tab_columns
      9            group by column_name
    10            having count(*)>1
    11         ) a,
    12         sys.all_tab_columns b
    13    where a.column_name=b.column_name
    14      and owner = 'SCOTT'
    15    order by a.column_name,
    16             b.table_name
    17  /
    COLUMN_NAME                    TABLE_NAME
    ACTIVE                         PRODUCTS
                                   TBL_ERRLOG
    ADDRESS                        ADDRESSBOOK_EXT
    ADJ_SALARY                     TESTME
                                   TESTME2
    ARTNO                          ARTICLE
                                   MUTATIONS
    ATTRIBUTE1                     TYPE2_TABLE
    CHANGE_VECTOR$$                MLOG$_EMP
                                   RUPD$_EMPSY.

  • Query Assistance - Sum numbers in an Alphanumeric field

    Hi,
    I am trying to write a SQL statement that will sum the numeric values in a field that contains both numeric and letters.
    Here is an example of the data I am working with-
    Table Name: mydata
    SSN Age Name
    123456789 25 Years John
    123456789 48 Years Mary
    909129456 52 Years Alice
    What I want to do is sum the total age of all people with the same social security number- e.g. 123456789 exists twice and the total of the ages is 73. The result I am trying to extrpolate using SQL is 73 without the word years included.
    Does anyone have an idea how I could write such a standard SQL statement?
    Thanks!!
    Mac
    Message was edited by: mac
    user623512

    If there is always only one natural number inside the age column, then:
    SQL> create table mydata (ssn,age,name)
      2  as
      3  select 123456789, '25 Years', 'John' from dual union all
      4  select 123456789, '48 Years', 'Mary' from dual union all
      5  select 909129456, '52 Years', 'Alice' from dual
      6  /
    Tabel is aangemaakt.
    SQL> select ssn
      2       , sum(to_number(regexp_replace(age,'[^[0-9]]*|(.)','\1'))) sum_age
      3    from mydata
      4   group by ssn
      5  /
           SSN    SUM_AGE
    123456789         73
    909129456         52
    2 rijen zijn geselecteerd.If all data is in the age column is a number followed by the string ' Years', then a regular SUBSTR will do as well.
    Regards,
    Rob.

Maybe you are looking for

  • Nokia lumia 920 slow charging

    Hi, I bought a new micro usb cable to have as a spare to charge my lumia 920 but have found that any micro USB cable that I use apart from the one that came with the phone will take forever to charge. The original cable when plugged into the mains wi

  • Business Process Publisher with Oracle XE

    Hello! I would like to make the Publisher Server use Oracle XE instead of the standard Oracle Lite. Which are the configurations to change? I guess that change only the DAO conf in the web.xml file is not enough. Thanks in advance. Walter Emma

  • 10.4.7 Intel Core install to G4 10.3.9

    I just purchased the Intel Core G5. Can I use the install disks on my G4 10.3.9 to upgrade that system. If so how? I put the disk in to see and it freaked! Tha

  • Deletion Flag for PR

    Dear Gurus, I want to put Deletion flag for abt 1000 PR's . Can anybudy tell me any tell me what is t-code or any other way ??? Thanks & Regards, Ishwar

  • After downloading ISO6 I can't make phone calls.

    After downloading ISO6 I can't make phone calls.  They are all failing.  Help