Extraction of extensible in PL/SQL SOAP envelope group

Hi all.

I have the following in an XMLTYPE variable in PL/SQL SOAP envelope.

<? XML version = "1.0" encoding = "UTF - 8"? >
< env:Envelope xmlns:env = "http://schemas.xmlsoap.org/soap/envelope/" container = "http://www.w3.org/2001/XMLSchema" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0 = "http://elmarwsoicdvmws/types/" >
< env:Body >
< ns0:getDVMValuesResponseElement >
< ns0:result >
< ns0:dvmValues > 10 < / ns0:dvmValues >
< ns0:dvmValues > 11 < / ns0:dvmValues >
< ns0:dvmValues > 12 < / ns0:dvmValues >
< ns0:errorText > Ok < / ns0:errorText >
< ns0:errorCode > 0 < / ns0:errorCode >
< / ns0:result >
< / ns0:getDVMValuesResponseElement >
< / env:Body >
< / env:Envelope > '

I can extract the code of error and ErrorText variable without too much effort (even if I don't know there are easier ways), but now I have to extract the repeating group of dvmValues in a variable of type table.

Any ideas/code snippets would be greatly appreciated, as I've read tons of docs and half the time they are too complex or too simplistic (given my ns0: variables), and it seems that many functions I use have been depricated.

Kind regards

Elmar

Hi Elmar,

Using a separate function to analyze the individual nodes is not necessary.
You can extract all with a single query, thus eliminating the need to access the same document several times.

For example, once you have the content in the RESP xmltype variable, you can do:

SQL> create type dvmValues_t as table of number;
  2  /

Type created

SQL> set serveroutput on
SQL>
SQL> DECLARE
  2
  3    resp         xmltype;
  4    v_errorText  varchar2(2000);
  5    v_errorCode  number;
  6    v_dvmValues  dvmValues_t;
  7
  8  BEGIN
  9
 10    resp := xmltype('
 11  
 12  
 13  
 14  
 15  10
 16  11
 17  12
 18  Ok
 19  0
 20  
 21  
 22  
 23  ');
 24
 25    select x.errorText
 26         , x.errorCode
 27         , cast(
 28             multiset(
 29               select dvmValue
 30               from xmltable('*' passing x.dvmValues
 31                                 columns dvmValue number path '.')
 32             )
 33             as dvmValues_t
 34           )
 35    into v_errorText
 36       , v_errorCode
 37       , v_dvmValues
 38    from xmltable(
 39           xmlnamespaces(
 40             'http://schemas.xmlsoap.org/soap/envelope/' as "env"
 41           , default 'http://elmarwsoicdvmws/types/'
 42           )
 43         , '/env:Envelope/env:Body/getDVMValuesResponseElement/result'
 44           passing resp
 45           columns
 46             errorText  varchar2(2000)  path 'errorText'
 47           , errorCode  number          path 'errorCode'
 48           , dvmValues  xmltype         path 'dvmValues'
 49         ) x
 50    ;
 51
 52    dbms_output.put_line('Error Text = ' || v_errorText);
 53    dbms_output.put_line('Error Code = ' || v_errorCode);
 54
 55    for i in 1..v_dvmValues.count loop
 56      dbms_output.put_line('Value(' || to_char(i) || ') = ' || v_dvmValues(i));
 57    end loop;
 58
 59  END;
 60  /

Error Text = Ok
Error Code = 0
Value(1) = 10
Value(2) = 11
Value(3) = 12

PL/SQL procedure successfully completed
 

Tags: Oracle Development

Similar Questions

  • analyze a soap envelope

    I have a SOAP response envelope that I try to analyse using extractvalue.

    The answer is stored in an xmltype field in a table.

    Table
    create table ws_results
    (x xmltype);
    SOAP response
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
         <s:Header>
              <ActivityId CorrelationId="12855f8e-d2be-40c7-81d8-fafa3cf9a779" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">d24174d3-e095-460a-b9f8-2bae66efe813</ActivityId>
         </s:Header>
         <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
              <FetchResponse xmlns="urn: WA.Ecy.ADS.FacilitySite.Services">
                   <FacilitySiteId>99997167</FacilitySiteId>
              </FetchResponse>
         </s:Body>
    </s:Envelope>
    Here's the SQL code I try to use to obtain the Site ID of the installation
    select extractvalue(x,'/FetchResponse/FacilitySiteId') from ws_results;
    
    select extractvalue(x,'/FetchResponse/FacilitySiteId','xmlns="http://microsoft.com/wsdl/types/"')
    from ws_results
    It returns a null value.

    Seems like it should be simple enough and I'm sure I'm missing something small. Any help would be appreciated.

    Thank you, Tony

    If it looks like you have levels and different node names. In such cases, you can do a v_xml.existNode ('/ / FetchResponse ',' xmlns = "http://yourNameSpaceLocation" ') > 0 or v_xml.existNode ('/ / FaciltySiteResponse ',' xmlns = "http://yourNameSpaceLocation" ') > 0, failure and write your code accordingly.

    Ben

  • How to see the response SOAP envelope full of BPEL

    Is it possible to see the full answer of BPEL (header SOAP + SOAP Body) in Enterprise Manager? As in path of Flow, I find that the value of the output variable.

    I don't think so there is an option to display the full message of EM, but you can check out the following blog to record the complete message in the log file.

    http://www.albinsblog.com/2012/10/getting-SOAP-envelope-of.html#.UyAcAPmSySo

    Concerning

    Albin I

    http://www.albinsblog.com/

  • REST base BSF calls returns with SOAP envelope Addressing WSA namespaces

    We expose the OSB (sampleREST) Proxy service as a RESTful service that accepts requests HTTP (GET, POST etc.).
    For the HTTP GET method, the proxy service called BPEL process synchronous Composite SOA (HelloWorldProject).

    The HelloWorldProject is a simple synchronous BPEL process that returns the response in the form of "Namaste, < < nom_entree > >.

    OSB HTTP GET request:

    http:// < < hostname > >: < < port > > / sampleREST/proxy/sampleREST

    Answer:

    <? XML version = "1.0" encoding = "UTF-8"? >
    " < processResponse xmlns =" http://xmlns.Oracle.com/MySOAApplication/HelloWorldProject/HelloWorldBPEL "xmlns:env =" http://schemas.xmlsoap.org/soap/envelope/ "xmlns:wsa =" http://www.w3.org/2005/08/Addressing "> "
    < result > Namaste, nanan < / result >
    < / processResponse >

    Description of the problem:

    In response, there are 3 namespaces,
    ( 1) xmlns = "http://xmlns.oracle.com/MySOAApplication/HelloWorldProject/HelloWorldBPEL"(ce n'est PAS le problème) "
    ( 2) xmlns:env = 'http://schemas.xmlsoap.org/soap/envelope/"(c'est le problème) "
    ( 3) xmlns:wsa = 'http://www.w3.org/2005/08/addressing"(c'est le problème) "

    For a response from REST, we expect the CORRECT answer

    [Envelope response soap CONTAINER AND wsa address namaspaces]

    <? XML version = "1.0" encoding = "UTF-8"? >
    " < processResponse xmlns =" http://xmlns.Oracle.com/MySOAApplication/HelloWorldProject/HelloWorldBPEL "> "
    < result > Namaste, nanan < / result >
    < / processResponse >

    I downloaded the Code from the OSB project.

    How do I get the answer REMAINS without SOAP ENVELOPE and NAMES ADDRESSING WSA namespaces?

    Thank you very much
    Nagaraj donna
    + 91-7387483335

    Hi all

    ATLAST, Oracle has provided a fix for this problem. I had raised SR with MOS.

    PFB the SR details to download the fix for this bug fix.

    Calls for expressions of OSB with SOAP and envelope WSA dealing of namespaces (Doc ID 1635230.1) is STILL based

    I hope this helps.

    Many thanks to all for your continued support and suggestions.

    Thank you very much

    Nagaraj donna

    + 91-7387483335

  • Suggestion: Add option to Soap envelopes to separate the dump file

    Currently, the Onyx log exports all envelopes in the journal of general Onyx.

    It's ok in most cases, but sometimes, it would be useful to be able to empty the Soap envelopes in a separate file.

    Type of a SOAP file 'raw '.

    ____________

    Blog: LucD notes

    Twitter: lucd22

    Hi LucD,

    Thanks for the suggestion! Similar functionality is already planned for a future release. It will provide easier access to the raw SOAP messages.

    Kind regards

    Ignat

  • PL/SQL: ORA-00934: Group feature is not allowed here

    Hello

    I write a PL/SQL procedure. The structure is like:

    SET SERVEROUTPUT ON;
    CREATE or REPLACE procedure abc

    IS
    v_total_ip_rec number (14);
    v_total_op_rec number (14);
    v_total_rec number (14);


    BEGIN
    SELECT SUM (CASE
    WHEN < condition 1 >
    THEN 1
    0 OTHERWISE
    END
    ) in v_total_ip_rec.
    SUM (CASE
    WHEN < condition 2 >
    THEN 1
    0 OTHERWISE
    END
    ) in v_total_op_rec.
    SUM (1) in v_total_rec
    OF A, B
    WHERE A.Col1 = B.Col1;

    EXCEPTION
    WHILE OTHERS THEN
    raise_application_error (-20001,' an error has occurred - ' |) SQLCODE |' - ERROR - ' | SQLERRM);
    END;


    When I run this procedure it gives me following error:
    "PL/SQL: ORA-00934: Group feature is not allowed here."

    Someone has an idea?

    Any help would be appreciated.

    Thank you.

    Should I have any special role?

    Have you checked if synonyms exist for tables?
    Please check in this order:

    #1-synonymes appropriate
    #2-appropriate privileges
    #3-appropriate roles

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • Extraction of data from MS SQL .bak file

    Hi all

    I received a MS SQL .bak file and need to extract the data into it, what should I do to achieve this?

    In addition, what is a bak file? It's a backup for a database file? I remember that I read somewhere that backup database has several different method (for example, the differential backup, the full backup), which will affect the restoration?

    Thank you

    Lee

    Hi Lee

    Your best resource for information is the Forum dedicated to suppoeting SQL.

    Category of the SQL Server:

    http://social.msdn.Microsoft.com/forums/en-us/category/SQLServer

    Concerning

  • Extract the connected connections (Developer SQL - Extension)

    Hi all

    Asked me to write an extension for the SQL Developer, but now I have a problem.

    My task was to write a simple browser which is able to connect to another program, but also to open .sql File in the normal SqlEditor

    The problem is now that it should be able to know all connections active (with the small cable through the icon) and generates buttons in the popup for it, so that the user can choose what DB that it wants to use to the right of the browser.

    I managed to do all of the work except for the context menu buttons, because I don't have that an active connection from:

    Connections.getInstance () .getActiveConnectionName)

    Then there is a simple way to get all the active connections to the SQL Developer?

    Thank you in advance!

    I already found the answer.

    I forget the method Connections.getInstance () .isConnectionOpen (s)

  • How to extract several Max (amount) with sql

    Hello

    I have this problem,

    I hace this table

    DISPLAY_NAME, MSISDN TRANSACTIONS

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

    CM, SA - MERCHANT I 829882904 75

    CM, SA - MERCHANT I 827102931 43

    CM, SA - MERCHANT I 17 824034968

    CM, SA - II MERCHANT 827102931 48

    4 selected lines.

    And I need to get the records corresponding to the highest trasactions by DISPLAY_NAME

    The must Resulet be something like

    DISPLAY_NAME, MSISDN TRANSACTIONS

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

    CM, SA - MERCHANT I 829882904 75

    CM, SA - II MERCHANT 827102931 48

    Any ideas?

    TXS so you can help

    Hello

    One way is a Request of Top - N , like this

    WITH got_r_num AS

    (

    SELECT x *- or list columns you want

    Rank () OVER (PARTITION BY display_name

    Operations ORDER BY DESC

    ) AS r_num

    FROM table_x

    -WHERE... - If you need any filtering, put it here

    )

    SELECT *- or the list of all columns except r_num

    OF got_r_num

    WHERE r_num = 1

    ;

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements)
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results in these places.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • SQL - SSIS likely grouping of records.

    Dear all,

    There is a requirement with our customer about the grouping of coordinates based on some of the fields in the contact table.

    I built an SSIS package and using the Component Manager of Script and Fuzzy Grouping. and its working perfectly according to the requirement.

    But unfortunately customer uses SQL Server 2012 Standard Edition.

    and fuzzy edition 2012 model, components of Transactions are not supported in SQL Server: (.)

    Kindly help me to get an alternative.

    Thanks in advance.

    Concerning

    Roopa

    Hello

    Support for SQL Server is not provided in these forums. On the other hand, it please repost your question Microsoft TechNet or MSDN here forum:

    SQL Server forums    (TechNet)

    SQL Server forums     (MSDN)

    Thank you.

  • SQL or PL/SQL-&gt; check a grouping of several criteria in the same group.

    Hello

    Oracle 11g. I need to check a set of data for multiple filtering criteria together. If the criterion is found, the FLAG_SET is updated.

    The example data:
    MEMBER     |     GROUPING             |     CODES     |     ROW_NUMBER     |     FLAG_SET
    001          |     1               |     A          |     45               |     0
    001          |     1               |     B          |     48               |     0
    002          |     1               |     C          |     45               |     0
    002          |     1               |     C          |     49               |     0
    002          |     1               |     A          |     52               |     0
    002          |     2               |     A          |     43               |     0
    002          |     2               |     B          |     62               |     0
    002          |     2               |     B          |     63               |     0
    003          |     1               |     A          |     72               |     0
    003          |     1               |     B          |     76               |     0
    My requirement is to test if a MEMBER within a GROUPING has an 'A' and 'B' (although there are several criteria to test on for example.) "C" and had "and they are prioritized. I would test a game both in a called proc).

    I need the following output:
    MEMBER     |     GROUPING             |     CODES     |     ROW_NUMBER     |     FLAG_SET
    001          |     1               |     A          |     45               |     1
    001          |     1               |     B          |     48               |     1
    002          |     1               |     C          |     45               |     0
    002          |     1               |     C          |     49               |     0
    002          |     1               |     A          |     52               |     0
    002          |     2               |     A          |     43               |     1
    002          |     2               |     B          |     62               |     1
    002          |     2               |     B          |     63               |     1
    003          |     1               |     A          |     72               |     0
    003          |     1               |     C          |     76               |     0
    I can't just update the indicators if a single 'A' CODE is found. He must have the 'A' and 'B '.
    I tried several ways, most recently LISTAGG put all grouped values of each line and the string for CODE analysis, I lose the ROW_NUMBER when this happens but it cannot be part of the coiled LISTAGG.

    Someone at - it ideas?

    Published by: chris001 on November 28, 2012 13:33

    Hello

    You can do it with a MERGE, something like statement:

    MERGE INTO table_x     dst
    USING   (
             SELECT    mmbr     -- MEMBER is an Oracle keyword
             ,           grpng     -- GROUPING is an Oracle keyword, too
             ,           CASE
                            WHEN  COUNT ( DISTINCT CASE
                                                  WHEN codes IN ('A', 'B')
                                       THEN codes
                                      END
                              ) = 2
                     THEN  1
              --       WHEN  ...
              --       THEN  2
              --       WHEN  ...
                     ELSE  0
                        END
             FROM      table_x
             GROUP BY  mmbr
             ,           grping
         )          src
    ON     (   src.mmbr       = dst.mmbr
         AND src.grpng       = dst.grpng
         )
    WHEN MATCHED THEN UPDATE
    SET     dst.flag_set     = src.flag_set
    WHERE     dst.flag_set   != src.flag_set
    ;
    

    According to your needs.
    If you would care to post CREATE TABLE and INSERT to your sample data (as it exists before the changes), then I could test this.

    You have not need PL/SQL for this, but, if you need to do it in PL/SQL for some reason, you can.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash on November 28, 2012 16:53

  • SQL - sorting and grouping.

    Hello

    I have question posted for two days, but no help of body...
    This link

    You place your order by comparing - SQL Experts pls help

    concerning

    Published by: Ayham on October 8, 2012 02:54

    If I am clear...

    SQL> with t as
      2  (select percentage,loc1,loc2,sum(case when percentage = 0 then 1
      3                     when loc1 in (l1,l2) then 0
      4                 when loc2 in (l1,l2) then 0
      5                 when l1 is null and l2 is null then 0
      6                 else 1
      7            end) over(order by rn) sm
      8  from (     select id,location,percentage,
      9                     regexp_substr(location,'\d+',1,1) LOC1,
     10                     regexp_substr(location,'\d+',1,2)  LOC2,
     11                     lag(regexp_substr(location,'\d+',1,1))
     12                     over(order by percentage desc) l1,
     13                     lag(regexp_substr(location,'\d+',1,2))
     14                     over(order by percentage desc) l2,
     15             row_number() over(order by percentage desc) rn
     16     from temp_value
     17     order by percentage desc
     18       )
     19  )
     20  select loc,min(sm)+1 grp
     21    from(
     22      select loc,rownum rn,sm
     23      from(
     24      select percentage,decode(rn,1,loc1,loc2) loc,sm
     25      from t a,
     26           (select 1 rn from dual union all
     27            select 2 from dual ) b
     28      order by percentage desc,decode(rn,1,loc1,loc2) asc
     29     )
     30  )
     31   group by loc
     32  order by min(sm),min(rn);
    
    LOC                         GRP
    -------------------- ----------
    4                             1
    5                             1
    2                             1
    1                             1
    6                             2
    3                             3
    
    6 rows selected.
    
  • SQL query to group data by Code and dates

    Hello

    I have the following table structure

    col1 col2 col3
    January 21, 2012 tested Code1
    January 20, 2012 tested Code1
    June 1, 2012 tested Code1
    June 1, 2012 tested Code2
    code 3 tested June 4, 2012

    so now

    The output should be something like

    code week1 week semaine2 3 semaine4 week5 until the last 14 weeks from the date that we run
    code 1 1 0 0 0 0
    Code2 1 0 0 0 0
    code 3 0 1 0 0 0

    where 1, 0 is in fact the charges and no sum and the week in this case perhaps should since we are in the second week, he should be

    code... .week3 may semaine4 peut week1 jun week2june


    Was looking for suggestions on how to achieve this.

    I guess that this would require some kind of a pivot query?

    Thank you
    Sun

    Hello

    Here's how you can make this pivot in Oracle 10.2. (In fact, it will work in Oracle 9.1 or higher.)

    WITH  got_week_num  AS
    (
         SELECT  error_code, date_logged
         ,     1 + FLOOR ( ( TO_DATE (:end_dt_txt, 'DD-Mon-YYYY') - date_logged)
                         / 7
                     )     AS week_num
         FROM    data_analysis
         WHERE     date_logged     >= TO_DATE (:start_dt_txt, 'DD-Mon-YYYY')
         AND     date_logged     <  TO_DATE (:end_dt_txt,   'DD-Mon-YYYY') + 1
    )
    ,     all_weeks     AS
    (
         SELECT     LEVEL               AS week_num
         ,     TO_CHAR ( 1 + TO_DATE (:end_dt_txt, 'DD-Mon-YYYY')
                       - (7 * LEVEL)
                   , 'fmDD-Mon-YYYY'
                   )          AS heading
         FROM    dual
         CONNECT BY     LEVEL <= 1 + FLOOR ( ( TO_DATE (:end_dt_txt,   'DD-Mon-YYYY')
                                             - TO_DATE (:start_dt_txt, 'DD-Mon-YYYY')
                                  )
                                / 7
                                )
    )
    SELECT       NULL                                   AS error_code
    ,       MIN (CASE WHEN week_num =  1 THEN heading END)     AS week_1
    ,       MIN (CASE WHEN week_num =  2 THEN heading END)     AS week_2
    --       ...
    ,       MIN (CASE WHEN week_num =  5 THEN heading END)     AS week_5
    FROM       all_weeks
           --
         UNION ALL
                --
    SELECT       error_code
    ,       TO_CHAR (COUNT (CASE WHEN week_num =  1 THEN 1 END))     AS week_1
    ,       TO_CHAR (COUNT (CASE WHEN week_num =  2 THEN 1 END))     AS week_2
    --       ...
    ,       TO_CHAR (COUNT (CASE WHEN week_num =  5 THEN 1 END))     AS week_5
    FROM       got_week_num
    GROUP BY  error_code
                 --
    ORDER BY  error_code     NULLS FIRST
    ;
    

    Output:

    ERROR_CODE WEEK_1      WEEK_2      WEEK_5
    ---------- ----------- ----------- -----------
               4-Jun-2012  28-May-2012 7-May-2012
    a          3           0           0
    b          0           2           1
    c          0           0           1
    

    Once more, the number of columns, such as aliases, is hard-coded in the query.
    If you want the number of columns, or their aliases depends on the data in the table, then you need dynamic SQL. See {message identifier: = 3527823}

    Did you ever what defined a "week" is in this query?
    The query above makes week_1 end to the given date (: end_dt_txt). The first week (in other words, an ioncluding: start_dt_txt) may have less than 7 days.
    If you want all the weeks to start Monday (in which case, the first and the last few weeks may have less than 7 days) see stew solution, using TRUNC (date_logged, 'IW').

  • SQL count (*) with Group of

    Hello

    I need help to fix this SQL.

    Fields in the table are like that.
    ID(PK)
    user_id
    user_name
    login_time(timestamp)
    Basically I want the values of user_id, user_name, last time the logged-in user and total number of times the user
    select  distinct user_id , user_name, login_date from USER_LOGIN
    where login_date in (select max(login_date) from USER_LOGIN group by user_id) 
    the above query is to give the result set with user_id, user_name, last time that the user logged on, but how can I include count (*) Group of user_id in the sql above
    select  distinct user_id , user_name, login_date, count(*) from USER_LOGIN
    where login_date in (select max(login_date) from USER_LOGIN group by user_id)  group by user_id 
    the sql above does not work.

    can you help me to get the number of records by user_id group.

    Thank you
    SK

    Hello

    Looks like you want something like this:

    SELECT       user_id
    ,       user_name
    ,       MAX (login_time)     AS last_login_time
    ,       COUNT (*)          AS total_rows
    FROM       user_login
    GROUP BY  user_id
    ,            user_name
    ;
    

    This assumes that user_login is off standard (like him are often seen), such that every row of the same user_id will also have the same user_name.

    I hope that this answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.

Maybe you are looking for