Doubt in Group by

I have doubt in group by clause.
System_log table contains
server_id,
system_cpu,
user_cpu,
time_log
as fields
I want to display distinct servers order by (system+user)
SELECT server_id
FROM system_log
WHERE time_log IN (SELECT MAX(time_log)
FROM system_log
GROUP BY server_id)
ORDER BY (system+ user) ASC
In this query, i'm not getting distinct server_id.
Can anyone correct me this query?

Try
SELECT sl.server_id
  FROM system_log sl
WHERE time_log =
       (SELECT MAX(time_log) FROM system_log sl2 WHERE sl.server_id = sl2.server_id GROUP BY server_id)or
SELECT sl2.server_id
  FROM (SELECT sl.*
              ,ROW_NUMBER() over(PARTITION BY sl.server_id ORDER BY sl.time_log DESC) RN
          FROM system_log sl) sl2
WHERE sl2.rn = 1Regards...

Similar Messages

  • Doubts Employee group

    Good Afternoon,
    I have a doutbs,
    When HR run an action of leave of an employee, the field Employee group have that be changed to Retired or not?, or only with the status of employment P0000-STAT2(0 Withdrawn) is necessary?.
    I want know , what is the better practice?
    Regards.

    Hi, Kapil Kaushal , Sikindar 
    The system work fine with the field P0000-STAT2, because i have configured the feature MSN 31 in the table T529A for the action of leave. and in the leave the system automatically change the status to Withdrawn.
    I want know if the field PERSG also i have that change to retire or not is necessary ?
    I am changing in the action of leave this field PERSG , but a consultant said that not is necessary, and i want kown ¿what is the best practice?
    This is the doubt.

  • Doubt regarding Grouping of Months

    Hello,
    Can i get any idea or any solution for grouping according to months.... <i.e> The output should appear like
    Jan --- Some calculation --- etc --- etc
    Feb --- Some calculation --- etc --- etc
    Mar --- Some calculation --- etc --- etc
    April --- Some calculation --- etc --- etc
    May --- Some calculation --- etc --- etc
    June --- Some calculation --- etc --- etc

    Hi,
    It depends if you want to group months from several years, or months within a year.
    Using the following sample data :with s as (
    select to_date('2009/01/13','yyyy/mm/dd') dt, 10 val from dual
    union all select to_date('2009/01/19','yyyy/mm/dd') dt, 15 val from dual
    union all select to_date('2009/02/09','yyyy/mm/dd') dt, 15 val from dual
    union all select to_date('2009/02/24','yyyy/mm/dd') dt, 20 val from dual
    union all select to_date('2010/01/11','yyyy/mm/dd') dt, 25 val from dual
    union all select to_date('2010/01/17','yyyy/mm/dd') dt, 30 val from dual
    union all select to_date('2010/02/10','yyyy/mm/dd') dt, 35 val from dual
    union all select to_date('2010/02/21','yyyy/mm/dd') dt, 40 val from dual
    select * from s;To group months within their respective year you can :SQL> with s as (
      2  select to_date('2009/01/13','yyyy/mm/dd') dt, 10 val from dual
      3  union all select to_date('2009/01/19','yyyy/mm/dd') dt, 15 val from dual
      4  union all select to_date('2009/02/09','yyyy/mm/dd') dt, 15 val from dual
      5  union all select to_date('2009/02/24','yyyy/mm/dd') dt, 20 val from dual
      6  union all select to_date('2010/01/11','yyyy/mm/dd') dt, 25 val from dual
      7  union all select to_date('2010/01/17','yyyy/mm/dd') dt, 30 val from dual
      8  union all select to_date('2010/02/10','yyyy/mm/dd') dt, 35 val from dual
      9  union all select to_date('2010/02/21','yyyy/mm/dd') dt, 40 val from dual
    10  )
    11  select to_char(trunc(dt,'month'),'Mon') month, sum(val) sval
    12  from s
    13  group by trunc(dt,'month')
    14  order by trunc(dt,'month') ;
    MON       SVAL
    Jan         25
    Feb         35
    Jan         55
    Feb         75Or you want to group months from several years, you can :SQL> with s as (
      2  select to_date('2009/01/13','yyyy/mm/dd') dt, 10 val from dual
      3  union all select to_date('2009/01/19','yyyy/mm/dd') dt, 15 val from dual
      4  union all select to_date('2009/02/09','yyyy/mm/dd') dt, 15 val from dual
      5  union all select to_date('2009/02/24','yyyy/mm/dd') dt, 20 val from dual
      6  union all select to_date('2010/01/11','yyyy/mm/dd') dt, 25 val from dual
      7  union all select to_date('2010/01/17','yyyy/mm/dd') dt, 30 val from dual
      8  union all select to_date('2010/02/10','yyyy/mm/dd') dt, 35 val from dual
      9  union all select to_date('2010/02/21','yyyy/mm/dd') dt, 40 val from dual
    10  )
    11  select to_char(dt,'Mon') Month, sum(val) sval
    12  from s
    13  group by to_char(dt,'Mon')
    14  order by to_number(to_char(to_date(to_char(dt,'Mon'),'Mon'),'mm')) ;
    MON       SVAL
    Jan         80
    Feb        110

  • Doubt on group by query

    i have the following two tables product and printer::: i want to find the makers of cheapest color printers.. this is the query which i wrote.. can any one pls help me on this to figure out my mistake??
    my query: select maker,min(price)as price from printer,product where color='y' and printer.model=product.model group by maker
    result of my query:
    maker
    price
    D
    270.0000
    E
    290.0000
    expected result:
    Maker
    price
    D
    270.0000
    product table:
    maker
    model
    type
    A
    1232
    PC
    A
    1233
    PC
    A
    1276
    Printer
    A
    1298
    Laptop
    A
    1401
    Printer
    A
    1408
    Printer
    A
    1752
    Laptop
    B
    1121
    PC
    B
    1750
    Laptop
    C
    1321
    Laptop
    D
    1288
    Printer
    D
    1433
    Printer
    E
    1260
    PC
    E
    1434
    Printer
    E
    2112
    PC
    E
    2113
    PC
    printer table:
    code
    model
    color
    type
    price
    1
    1276
    n
    Laser
    400.0000
    2
    1433
    y
    Jet
    270.0000
    3
    1434
    y
    Jet
    290.0000
    4
    1401
    n
    Matrix
    150.0000
    5
    1408
    n
    Matrix
    270.0000
    6
    1288
    n
    Laser
    400.0000

    Problem is the min(price) clause, it's giving 150 as the output which doesn't satisfy other conditions and thus no output. Try this.
    SELECT maker,
           price
    FROM   printer,
           product
    WHERE  color = 'y'
           AND printer.model = product.model
           AND price = (SELECT Min(price)
                        FROM   printer
                        where color = 'y');

  • Doubt using Group Layout

    Hello everybody, i have been using GroupLayout and I encountered a little problem that i could not solve. I would like to see if any of you are able to give me a hand with this.
    I try to add two components to a container (one over the other in Y AXE) , using the following code
    layout.setHorizontalGroup(layout.createSequentialGroup()
         .add(layout.createParallelGroup((GroupLayout.LEADING)))
              .add(tbToolPanel)
              .add(canvas.getGeneralPanel())
    layout.setVerticalGroup(layout.createSequentialGroup()
         .add(tbToolPanel)
         .add(canvas.getGeneralPanel())
    );The problem is that it just add the canvas.getGeneralPanel() component, the other does not appear, unless i comment the .add(canvas.getGeneralPanel()) lines.
    Do you have any idea of why this happens?
    Any suggestion would be helpfull.
    Thanks!

    GroupLayout is mostly used by IDE's so they can use a single layout manager to manage all components on a frame.
    For us humans its easier to mix and match layout managers to get the desired layout.
    I try to add two components to a container (one over the other in Y AXE)Sounds like a BoxLayout would be more suitable.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

  • Report - Grouping of Vendors

    Hi Gurus,
    I have a doubt on Grouping can anyone please help me regarding this. The issue is i displayed the vendors and many materials they are supplying like
    Vendor, No.of Material
    100, 5
    200, 11
    1000, 25
    and so on....................
    Now i want to group the the vendors based on materials like
    Range of Materials, No.of Vendors
    1 - 10, 5
    10-20, 25
    >20, 45
    So, can anyone help me how to display the report in this way.
    Thanks in Advance,
    Regards
    Ramakrishna Kamurthy

    Hi Pankaj,
    If you don't mind, could also send that document to my email: [email protected]
    Regards,
    Niel.

  • Purchase Group-ID & Purchase group Name

    Hi All
    My requirment is i need to populate purchase group ID and purchase group name in the alv.Please give me any FM for these values.
    First of all my doubt is group ID means?Is it char 3 type.?
    Thanks
    Vamsi

    Hi Mohan,
    Yes the 3 characters are the Purchasing group code, you can find the code and name in table HRP1000.
    To fetch those you can use the FM :
    BBP_PDH_PUT_PGRP_TO_WEB
    BBP_OM_STRUC_GET_PUSR_FROM_PGP
    BBP_OM_FIND_PURCH_GRPS
    Best Regards,
    Anil

  • Report on MM

    Hi Gurus,
    I have a doubt on Grouping can anyone please help me regarding this. The issue is i displayed the vendors and many materials they are supplying like
    Vendor, No.of Material
    100, 5
    200, 11
    1000, 25
    and so on....................
    Now i want to group the the vendors based on materials like
    Range of Materilas, No.of Vendors
    1 - 10, 5
    10-20, 25
    >20, 45
    So, can anyone help me how to display the report in this way.
    Thanks in Advance,
    Regards
    Ramakrishna Kamurthy

    HI ,
    You have to write routine for "Range of materials".
    Like the following.
    If ( Material_VAL >= 1 and Material_VAL < 10 ).
           Range of Material = '1'.
    elseIf ( Material_VAL >= 10 and Material_VAL < 20 ).
           Range of Material = '2'.
    elseIf ( Material_VAL >= 20 ).
           Range of Material = '3'.
    endif.
    While doing the report, just you place "Range of material" into rows (Select the property as "TEXT") and "Material Value in Columns. it will display value as you desired.
    Thanks and regards
    Rajesh.

  • Report on SD

    Hi Gurus,
    I have a doubt on Grouping can anyone please help me regarding this. The issue is i displayed the vendors and many materials they are supplying like
    Vendor, No.of Material
    100, 5
    200, 11
    1000, 25
    and so on....................
    Now i want to group the the vendors based on materials like
    Range of Materilas, No.of Vendors
    1 - 10, 5
    10-20, 25
    >20, 45
    So, can anyone help me how to display the report in this way.
    Thanks in Advance,
    Regards
    Ramakrishna Kamurthy

    Number of Materials is characteristics and you want to measure it by giving a range, if that is the case then you need to create formula variable with replacement path for the material and once you get the variable, create a calculated  key figure on that variable.
    thanks.
    Wond

  • Doubt in Selection-Screen for Program type "Function Group"

    Hi Gurus,
    I created a Function group in that i created one screen and writtem the Screen flow logic. In that screen I called a Function module "COMPLEX_SELECTIONS_DIALOG" For Creating a selection-Screen.
    The code snippet is like below.
    CASE ok_code .
        WHEN c_clk1.
          CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'
         EXPORTING
           title                   = text-002
           text                    = 'Material Number'
           signed                  = 'X'
            lower_case              = ' '
            no_interval_check       = ' '
             just_display            = ' '          " Un commented by Srihari
             just_incl               = 'X'          " Un commented by Srihari
            excluded_options        =
            description             =
            help_field              =
            search_help             =
           tab_and_field           = st_tab
          TABLES
            range                   = r_matnr
         EXCEPTIONS
           no_range_tab            = 1
           cancelled               = 2
           internal_error          = 3
           invalid_fieldname       = 4
           OTHERS                  = 5.
    it works fine. But the problem is if i click the multiple selection button for the select-option in selection screen and enter the values and copy those value. In the multiple selection button green button is not coming like noram report selection-screen. Please remember I used the program type as "Function Group" not "Module Pool".
    Please send your suggestions.
    Thanks,
    Srihari.

    Ok, I am not 100% sure, if I understand you correctly, you said, you created one screen to 'simulate' a standard selection screen behavior without using select-options statement?
    If that's not correct, could you please post a few more details on what exactly you are doing.
    I had to 'simulate' a select-option behavior which I did as follows:
    - I created a range variable to store the values (s_ctby)
    - on the screen I defined the LOW (s_ctby-low), HIGH (s_ctby-high) and the multiple selection field pushbutton
    - In the PBO I set the icons for the multiple selection pushbutton
      READ TABLE s_ctby INDEX 2 TRANSPORTING NO FIELDS.
      IF sy-subrc NE 0.
        gv_createby = gc_icon_enter_data.
      ELSE.
        gv_createby = gc_icon_disp_data.
      ENDIF.
    - In the PBO make sure that any values entered on the screen are transferred to the range
    * transfer any changed values into the correct range for user transaction
    * (screen 0110) because that screen just 'simulates' a selection screen
    * so we have to make sure that any data the user enters in the selection
    * fields is passed into the appropriate ranges
      IF sy-tcode EQ gc_trans_user.
    *   created by
        IF NOT s_ctby-high IS INITIAL.
          s_ctby-sign   = c_i.
          s_ctby-option = c_bt.
          IF s_ctby[] IS INITIAL.
            INSERT s_ctby INDEX 1.
          ELSE.
            MODIFY s_ctby INDEX 1.
          ENDIF.
        ELSEIF NOT s_ctby-low  IS INITIAL AND
                   s_ctby-high IS INITIAL.
          s_ctby-sign   = c_i.
          s_ctby-option = c_eq.
          IF s_ctby[] IS INITIAL.
            INSERT s_ctby INDEX 1.
          ELSE.
            MODIFY s_ctby INDEX 1.
          ENDIF.
        ELSEIF s_ctby-low  IS INITIAL AND
               s_ctby-high IS INITIAL.
          DELETE s_ctby INDEX 1.
        ENDIF.
    - If the user hits the multiple selection pushbutton
        WHEN gc_fc_create_by.
    *     if the user hits the multiple selection button on the screen
    *     we call the standard SAP functionality to show the multiple
    *     selection popup SAP uses on a standard selection screen
          CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'
            EXPORTING
              title             = text-t02
            TABLES
              range             = s_ctby
            EXCEPTIONS
              no_range_tab      = 1
              cancelled         = 2
              internal_error    = 3
              invalid_fieldname = 4
              OTHERS            = 5.
          IF sy-subrc NE 0 AND NOT sy-msgty IS INITIAL.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
    *     now update the header line so the screen fields display the correct values
          CLEAR s_ctby.
          READ TABLE s_ctby INDEX 1.
    Hope that helps,
    Michael

  • Using GROUP BY Doubt

    Eg: i have an employees table
    With CURADDRIND 0's and 1's and CREATEDATE is a DATE Column
    i want to query and get the Latest CURRADDRIND for a particular employee for the maximum of CREATE DATE
    I Have data like this
    empid curraddrind createdte
    130 0 9/10/2008
    130 1 9/15/2008
    130 0 8/15/2008
    i want output
    1 9/15/2008
    i wrote query like this
    select curraddrind,max(createdte) from emp
    where empid=130
    group by curraddrind
    i am getting
    1 9/15/2008
    0 9/10/2008-->this also ..but shud be omitted
    can anyone give solution for this ..
    Thanks in advance

    Or using only one table access:
    SQL> create table t (empid,curraddrind,createdte)
      2  as
      3  select 130, 0, date '2008-09-10' from dual union all
      4  select 130, 1, date '2008-09-15' from dual union all
      5  select 130, 0, date '2008-08-15' from dual
      6  /
    Table created.
    SQL> select max(curraddrind) keep (dense_rank last order by createdte) curraddrind
      2       , max(createdte) createdte
      3    from t
      4   where empid = 130
      5  /
    CURRADDRIND CREATEDTE
              1 15-09-2008 00:00:00
    1 row selected.Regards,
    Rob.

  • Doubt regarding avoiding group by function

    i just came to know about a query which will avoid group by function,
    select sum(column_name) over ( partition by <coulmns> order by <solumns> )
    from <table_name>
    now columns specified in the partition by clause, are the one which will be specified under group by clause, i know this works, but can anyone expalain the meaning and significance of over keyword and is it a function, i mean with respect to SQL language that syntax seems to be very much different isn't it???
    cheere

    Hi
    Analytic functions are not alternative for group by.
    Analytic functions are the last set of operations performed in a query except for the
    final ORDER BY clause. All joins and all WHERE, GROUP BY, and HAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDER BY clause.
    And regarding your question,
    see this example from oracle documentation
    The following example calculates, for each manager in the sample table
    hr.employees, a cumulative total of salaries of employees who answer to that
    manager that are equal to or less than the current salary. You can see that Raphaely and Cambrault have the same cumulative total. This is because Raphaely and Cambrault have the identical salaries, so Oracle adds together their salary values and applies the same cumulative total to both rows.
    SELECT manager_id, last_name, salary,
    SUM(salary) OVER (PARTITION BY manager_id ORDER BY salary
    RANGE UNBOUNDED PRECEDING) l_csum
    FROM employees;
    MANAGER_ID LAST_NAME SALARY L_CSUM
    100 Mourgos 5800 5800
    100 Vollman 6500 12300
    100 Kaufling 7900 20200
    100 Weiss 8000 28200
    100 Fripp 8200 36400
    100 Zlotkey 10500 46900
    100 Raphaely 11000 68900
    100 Cambrault 11000 68900
    100 Errazuriz 12000 80900
    149 Taylor 8600 30200
    149 Hutton 8800 39000
    149 Abel 11000 50000
    201 Fay 6000 6000
    205 Gietz 8300 8300
    King 24000 24000
    For clear understanding read the following point:
    Whenever the order_by_clause results in identical
    values for multiple rows, the function returns the same result for
    each of those rows
    ITS THE CUMULATIVE SUM HERE.
    SO,IF TRY GIVING SAME NAME FOR ALL EMPLOYESS AND see the same result as you were getting with (partition by dept).
    so , sum function which u are using here is analytic function and so results in cumulative sum. and when identical values are identified, same result is displayed.
    Hope you got it!
    Cheers,
    Kishore KVR

  • GROUP BY doubt

    Hi All,
    I am aware that what ever column we select we will have to enter it in group by clause if we perform aggregate function in select statement. in my below query, i am trying to give group by column position like (group by 1,2,3). but its not working. its still keeps on telling "ORA-00979: not a GROUP BY expression"
    can you please help me with this? how i should place group by with the columns in select statement with position?
    WITH user_lang_permsn
    AS
       (SELECT ur.lang_id
        FROM permsn_t per
        INNER JOIN role_permsn_t rp
        ON   rp.permsn_id = per.permsn_id
        INNER JOIN usr_role_t ur
        ON   ur.role_id = rp.role_id
        WHERE ur.usr_id = 1
        AND   per.permsn_name = 'LanguageTranslation'
        UNION
        SELECT upm.lang_id
        FROM   permsn_t p
        INNER JOIN usr_permsn_t upm
        ON    upm.permsn_id = p.permsn_id
        WHERE upm.usr_id = 1
        AND   p.permsn_name = 'LanguageTranslation'
        UNION
        SELECT f_get_central_language
        FROM   dual)
        SELECT c.chr_code "char code",
                             f_char_dscr(pl.prpsd_chr_id,   dc.dscr_id,   1) "characteristic type",
                             count(cvd.chr_val_id),
                             cvd.chr_val_dscr,
                             CASE
                                  WHEN l.lang_id = f_get_central_language THEN
                                     NULL
                                  ELSE
                                     l.lang_dscr
                                  END
                             AS lang_dscr,
                             CASE
                                  WHEN (cvd.lang_id = f_get_central_language AND cvd.trans_st = 'P') THEN
                                       'N'
                                  WHEN cvd.chr_val_dscr IS NULL THEN
                                       'N'
                                  ELSE
                                       'Y'
                                  END
                             AS display
                      FROM  prpsl_lst_t pl --,      user_lang_permsn ulp
                      INNER JOIN chr_t c
                      ON    pl.prpsd_chr_id  = c.chr_id
                      INNER JOIN dscr_config_t dc
                      ON    dc.rgn_id        = c.rgn_id
                      AND   dc.enty_dscr     = 'CHARACTERISTIC'
                      AND   dc.main_dscr_ind = 'Y'
                      INNER JOIN dscr_config_t cdc
                      ON    cdc.rgn_id        = c.rgn_id
                      AND   cdc.enty_dscr     = 'CHR_VAL'
                      AND   cdc.main_dscr_ind = 'Y'
                      CROSS JOIN user_lang_permsn ulp
                      INNER JOIN chr_val_dscr_t cvd
                      ON    cvd.chr_val_id    = pl.prpsd_chr_val_id
                      AND   cvd.dscr_id       = cdc.dscr_id
                      AND   cvd.lang_id       = ulp.lang_id
                      INNER JOIN lang_t l
                      ON    l.lang_id         = cvd.lang_id
                      WHERE pl.prpsl_status_ref_id = pkg_grd_global.F_GET_REF_ID_BY_VAL('PROPOSED','STATUS')
                      AND EXISTS
    (SELECT 'e' --product groups related to the proposed char value
                                    FROM   prpsl_attr_t pa
                                    INNER JOIN usr_chr_val_assoc_t ucv -- user scope
                                    ON     ucv.chr_val_id           = pa.prpsl_attr_val_id
                                    WHERE  pa.prpsl_id              = pl.prpsl_id
                                    AND    pa.prpsl_attr_typ_ref_id = pkg_grd_global.f_get_ref_id_by_val('PRODUCTGROUP',   'PROPOSAL ATTRIBUTE TYPE')
                                    AND    ucv.usr_id               = 1)
                                    AND  EXISTS
                                    (SELECT 'e' -- language permission check
                                    FROM   prpsl_attr_t pa
                                    INNER JOIN user_lang_permsn up
                                    ON     up.lang_id = pa.prpsl_attr_val_id
                                    WHERE  pa.prpsl_id              = pl.prpsl_id
                                    AND    pa.prpsl_attr_typ_ref_id = pkg_grd_global.f_get_ref_id_by_val('LANGUAGE',   'PROPOSAL ATTRIBUTE TYPE'))
                                    AND  EXISTS (SELECT 'e' -- language permission check
                                    FROM   prpsl_attr_t pa
                                    INNER JOIN
                                           (SELECT ur.rgn_id
                                            FROM permsn_t per
                                            INNER JOIN role_permsn_t rp
                                            ON   rp.permsn_id = per.permsn_id
                                            INNER JOIN usr_role_t ur
                                            ON   ur.role_id = rp.role_id
                                            WHERE ur.usr_id = 1
                                            AND   per.permsn_name = 'LanguageTranslation'
                                            UNION
                                            SELECT upm.rgn_id
                                            FROM   permsn_t p
                                            INNER JOIN usr_permsn_t upm
                                            ON    upm.permsn_id = p.permsn_id
                                            WHERE  upm.usr_id = 1
                                            AND    p.permsn_name = 'LanguageTranslation') up
                                    ON     up.rgn_id = pa.prpsl_attr_val_id
                                    WHERE  pa.prpsl_id              = pl.prpsl_id
                                    AND    pa.prpsl_attr_typ_ref_id = pkg_grd_global.f_get_ref_id_by_val('COUNTRY',   'PROPOSAL ATTRIBUTE TYPE'))
                                    GROUP BY cvd.chr_val_id,c.chr_code,f_char_dscr(pl.prpsd_chr_id,   dc.dscr_id,   1),cvd.chr_val_dscr
                                            

    user 777111 wrote:
    Hi All,
    I am aware that what ever column we select we will have to enter it in group by clause if we perform aggregate function in select statement. in my below query, i am trying to give group by column position like (group by 1,2,3). but its not working. its still keeps on telling "ORA-00979: not a GROUP BY expression"
    can you please help me with this? how i should place group by with the columns in select statement with position? I believe you can not use positional references in GROUP BY. You have to use column names. So a "group by 1,2,3" results in grouping by constant values. (and hence the error)
    You can use positional references in ORDER BY.

  • Group By -- Having Clause related doubt.

    Hello,
    Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?
    If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ...
    SO how does Having works before grouping the Results..??

    Hi,
    Aijaz Mallick wrote:
    Hello,
    Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?What happens when you try it?
    If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ... Right; the HAVING clause is like another WHERE clause.
    The WHERE clause is applied before the GROUP BY is done, and the aggregate functions are computed.
    The HAVING clause is applied after the GROUP BY is done, and the aggregate functions are computed, so you can use aggregate functions in the HAVING clause.
    SO how does Having works before grouping the Results..??The order in which clauses appear in your code isn't necessarily the order in which they are performed. For example,
    SELECT    job
    ,         COUNT (*)  AS cnt
    FROM      scott.emp
    GROUP BY  job;Does it confuse you that this query can reference COUNT (*) in the SLECT clause, which is before the GROUP BY clause?
    The SELECT clause which always comes before the GROUP BY clause in code. That does not mean that the SELECT clause is completed before the GROUP BY clause is begun.
    If the documentation says that clauses must be in a certain order, then use that order, even if your current version of Oracle allows them to be in a different order. There's no guarantee that the next version of Oracle will allow something that was always said to be wrong.

  • Doubts on Program Groups

    Hi All,
    Program Groups has different meaning in ABAP.Could any body help me know the exact information on this... How the common data part will working according to this...
    Thank you...

    check this out
    link: [http://help.sap.com/saphelp_46c/helpdata/en/e4/2adbd7449911d1949c0000e8353423/content.htm]
    reward if helpful
    raam

Maybe you are looking for