Want to sort the columns while using GROUP BY ROLLUP.

Want to order the below query using by "News' column in descending order and "Email address" column in Ascending order.
Note: Sorting should not bring Total value to top. It is happening now.
{code}
SELECT decode(grouping(NVL(Client, 'NA')),1, 'Totals', NVL(Client, 'NA')) "Email (Login ID)",
Location "Location",
SUM(News) "News",
SUM(Website) "Website",
FROM VW_FX_USERDATA
GROUP BY ROLLUP (((NVL(Client, 'NA')),Location,1, 'Totals', NVL(Client, 'NA')))
{code}
PLease let me know if you need any details.
Edited by: Nagaraja Akkivalli on Sep 23, 2011 4:04 PM

Thanks hm,
Let me explain bit clearly.
Say I am getting resultset as below.When I am executing above mentioned query.
Client*        Location    News      Website       Total
ABC        YD           9     0           4
BCD        HB           12     7           13
CDE        SI            1     18           3
JNM        BI          25     0           4
ZZZ        TI          0     221           77
XYZ        TT          0     1           1
Totals                      47     247           435I want it to as below. Here records are sorted in the descending order of the News Count and then Client*
Client*        Location    News      Website       Total
JNM        BI          25     0           4
BCD        HB           12     7           13
ABC        YD           9     0           4
CDE        SI            1     18           3
XYZ        TT          0     1           1
ZZZ        TI          0     221           77
Totals                      47     247           435If I order the column by News in the descending order, it is taking Totals value to the top. (Since I am using GROUP BY ROLLUP).
Note: Sorting should not be applied to Totals.
Hope this is clear to you. Let me know if you need any details.
Thanks and Regards
Nagaraja Akkivalli.

Similar Messages

  • How to sort specific column when using GROUPING SETS in SQL Server?

    If I remember correctly, in SQL Server, it is not recommended to use "ORDER BY" when there's already a GROUP BY GROUPING SETS.
    I have two columns: [UPC#] & [Description] both are varchar.
    My grouping sets is like this:
    GROUP BY
    GROUPING SETS
    ([UPC],[Description])
    I don't have 'ORDER BY' but it's automatically sorting the Description column.
    If I added a 3rd column, sum(Qty), then it doesn't sort by Description anymore. But if I added
    ORDER BY [Description]
    then the grand total of sum(Qty) will be at the first row instead of the last.
    Is there a way to sort the Description column and still let the grand total of sum(Qty) be at the last row instead?
    Thanks.

    Yes, it works.
    Thank you.
    Could you kindly explain the logic?
    I don't quite understand the "= 3 THEN 1 ELSE 0" part.
    Is the #3 mean the column index 3?
    GROUPING_ID returns a bit mask value depending on number of columns grouped in the result 
    So when you do GROUPING_ID(([UPC]),([Description]))
    it has two columns UPC and Description so bit mask will be as follows
    0 ie 00 for rows grouped by both UPC and Description fields
    1 ie 01 for rows grouped by UPC ie UPC subtotals
    2 ie 10 for rows grouped by Description ie Description subtotals
    3 ie 11 for rows not grouped by both columns ie Grand total
    see
    http://msdn.microsoft.com/en-IN/library/bb510624.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Sorting the column of VARCHAR in report

    Hi,
    I want to sort the column in report with the following scenario,
    I have a column name with PERIOD as VarChar with values APR-11,FEB-11,JAN-11,JUN-11,MAR-11,MAY-11 in a report
    As you can see, It is sorting in Alphabetic order but I need to arrange in JAN-11,FEB-11,MAR-11,APR-11,MAY-11,JUN-11
    So can anyone has a good work around solution?
    regards
    Vj

    Here is your challenge. How do you get Jan-12 to come after Dec-11? Adil's solution is partial. It works only for the current year. Once you cross over to the next year, it stops working because you are only sorting the month. You must include the year to make the solution complete. So here is a solution that always works. It involves some math so I'll explain the math first.
    Let's look at your values:
    Jan-11
    Feb-11
    Dec-11
    Jan-12
    If you convert each month to a number (i.e., Jan = 1, Feb =2... etc.) and then multiply the year by 1000 and finally add them together, we get this:
    Jan-11 1 --> 11001
    Feb-11 2 --> 11002
    Dec-11 12 --> 11012
    Jan-12 1 --> 12001
    You get the picture. The last column will be in the order you seek because the integer will always be greater than the previous month-year even at the transition from December to January. BTW, I multiplied the two digit year by 1000 to ensure that there would be no overlap.
    Now you can sort by this third column. Here is the code that does this:
    CAST(CASE WHEN LEFT(Table.PERIOD, 3) = 'Jan' THEN '1' WHEN LEFT(Table.PERIOD, 3) = 'Feb' THEN '2' WHEN LEFT(Table.PERIOD, 3) = 'Mar' THEN '3' WHEN LEFT(Table.PERIOD, 3) = 'Apr' THEN '4' WHEN LEFT(Table.PERIOD, 3) = 'May' THEN '5' WHEN LEFT(Table.PERIOD, 3) = 'Jun' THEN '6' WHEN LEFT(Table.PERIOD, 3) = 'Jul' THEN '7' WHEN LEFT(Table.PERIOD, 3) = 'Aug' THEN '8' WHEN LEFT(Table.PERIOD, 3) = 'Sep' THEN '9' WHEN LEFT(Table.PERIOD, 3) = 'Oct' THEN '10' WHEN LEFT(Table.PERIOD, 3) = 'Nov' THEN '11' WHEN LEFT(Table.PERIOD, 3) = 'Dec' THEN '12' END AS INTEGER)+CAST(RIGHT(Table.PERIOD, 2) AS INTEGER)*1000
    This solves your problem now even when the month-year crosses to the next year. There you go!

  • How do I sort or reorganize while using the new Numbers 3.0

    How do I sort or reorganize while using the new Numbers 3.0; I can't seem to find the sort icon.
    Thanks
    ActiveSolutions

    Yes, I understand the convenience of the old Reorganize panel. I thought it was great. The problem is (I'm guessing) that it is really hard to do something like that in Numbers iOS and Numbers for iCloud. So they gave us features that are more likely to work across all platforms.
    If you need to sort just selected rows you could put the =A&C&B formula (or whatever order you need) in just the rows you need to sort. Leave the other cells in column D blank.
    Or, if you're doing a LOT of partial sorting like that maybe you should have the data in separate tables anyway.
    Not saying it's great... just saying there are workarounds... until (if) something like the Reorganize panel comes back by popular acclaim. 
    SG

  • How do I sort songs in the iTunes store?  You used to be able to click on the column header to sort the column (ie Popularity)?

    How do I sort songs in the iTunes store?  You used to be able to click on the column header to sort the column (ie Popularity)?

    It seems this is a "backwards" upgrade from Apple in their iTunes 11 release....like you, I used to use that function in the iTunes store to sort through and decide which song version to purchase.   (For a large returned list of songs...see all...then sort by any of the headers, including Popularity...this functionality is now gone.)  
    The iPad always suffered from this...was never able to sort on those same column headers with an iPad.   It seems, this new iTunes release killed that functionality on the Mac as well.
    Just one of the few things that went wrong with number 11!
    Better luck next time,

  • Return all the column values using the F4IF_INT_TABLE_VALUE_REQUEST

    Hi,
    How to return all the column values using the F4IF_INT_TABLE_VALUE_REQUEST?
    For example : if the row has 3 columns then after selecting the particular row, the RETURN_TAB internal table should contain all the three column values.
    Regards,
    Raghu

    Hi,
       Try the following...
    DATA : it_fields like help_value occurs 1 with header line.
    data: begin of w_vbap,
            vbeln      like vbap-vbeln,    
            posnr      like vbap-posnr,   
            werks      like vbap-werks,  
          end of w_vbap.
    data: i_vbap   like w_vbap   occurs 0 with header line,
             w_fields type help_value,
          i_dfies type table of dfies,
          i_return_tab type table of ddshretval with header line,
          i_field  type dfies.
      select vbeln posnr werks
          from vbap into table i_vbap up to 5 rows.
    if sy-subrc = 0.
       sort i_vbap by vbeln.
    endif.
      clear it_fields[] , it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'VBELN'.
      it_fields-selectflag = c_on.
      append it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'POSNR'.
      it_fields-selectflag = space.
      append it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'WERKS'.
      it_fields-selectflag = space.
      append it_fields.
      loop at it_fields into w_fields.
        i_field-tabname   = w_fields-tabname.
        i_field-fieldname = w_fields-fieldname.
        i_field-keyflag   = w_fields-selectflag.
        append i_field to i_dfies.
      endloop.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
          retfield               = 'VBELN'
         window_title           = 'Select'
        tables
          value_tab              = i_vbap
          field_tab                = i_dfies
          return_tab             = i_return_tab
       exceptions
         parameter_error        = 1
         no_values_found        = 2
         others                 = 3
      read table i_return_tab into w_return_tab index 1.
      if sy-subrc = 0.
      endif.
    Regards,
    Srini.

  • When double clicking on alv ,want to get the column name

    Hello there,
        I'm displaying the value of internal table in an alv using Reuse_alv_grid_display method ,using fieldcatalog.I want to know the column name when double clicking on a particular line .If the the fieldname is 'MATNR' then i want to check that column name.
        If anybody have any idea plz terply me.
    Thanking you neon

    for that you have to use the USER_COMMAND event.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       I_CALLBACK_USER_COMMAND      = 'USER_COMMAND'
       IT_FIELDCAT                       = it_fcat
      TABLES
        t_outtab                          = itab
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    FORM USER_COMMAND using ucomm type sy-ucomm
                                                   selfield type slis_selfield.
    data: fieldname(30).
    case ucomm.
    when '&IC1'.
    case selfield-fieldname.
       when 'MATNR'.
        message 'clicked on Matnr' type 'I'.
       when 'POSNR'.
       endcase.
    endcase.
    ENDFORM.

  • How to fix the width of the column when using alv table

    Hi ,
    I am displaying the contents in a table. Of course using alv component i displayed the content. Now the problem is the column width is not fixed with value of the table entries( based on the domain length level). As  length  of field increases or decreses as the length of the content increases or decreases. I wanted to fix the column width whatever be the length of the contents.
    Can any one help in this regard ?
    Thanks Pons.

    Hi,
    Please find the code related to your problem.
    METHOD configure_alv .
    data declaration for column settings
      DATA  : lr_column_settings   TYPE REF TO if_salv_wd_column_settings,
              lr_col_header        TYPE REF TO cl_salv_wd_column_header,
              lt_columns           TYPE salv_wd_t_column_ref,
              ls_column            TYPE salv_wd_s_column_ref.
    data declaration for table settings
      DATA : lr_salv_wd_table_ctr  TYPE REF TO iwci_salv_wd_table,
             lr_table_settings_ctr TYPE REF TO if_salv_wd_table_settings,
             lr_header_ctr         TYPE REF TO cl_salv_wd_header.
    Variables for drop-down and inpufield reference
      DATA : lr_drdn_by_key        TYPE REF TO cl_salv_wd_uie_dropdown_by_key,
             lr_input_field        TYPE REF TO cl_salv_wd_uie_input_field,
             l_header              TYPE string.
    get ALV Component <CONTRACT_DETAILS>
      lr_salv_wd_table_ctr = wd_this->wd_cpifc_payment_detail( ).
      wd_this->alv_config_table = lr_salv_wd_table_ctr->get_model( ).
    set visible row count
      lr_table_settings_ctr ?= wd_this->alv_config_table.
      lr_table_settings_ctr->set_visible_row_count( '5' ).
      lr_table_settings_ctr->set_read_only( abap_false ).
      lr_table_settings_ctr->set_grid_mode( ).
      lr_table_settings_ctr->set_width(
        EXPORTING
          value = '980PX' ).
      wd_this->alv_config_table->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event ).
      wd_this->alv_config_table->if_salv_wd_std_functions~set_pdf_allowed( abap_false ).
      wd_this->alv_config_table->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
      wd_this->alv_config_table->if_salv_wd_std_functions~set_edit_insert_row_allowed( abap_false ).
      wd_this->alv_config_table->if_salv_wd_std_functions~set_edit_delete_row_allowed( abap_true ).
      wd_this->alv_config_table->if_salv_wd_std_functions~set_export_allowed( abap_false ).
      wd_this->alv_config_table->if_salv_wd_std_functions~set_edit_check_available( abap_false ).
      CLEAR: l_header.
      l_header = wd_assist->if_wd_component_assistance~get_text( '030' ).
      lr_header_ctr = lr_table_settings_ctr->get_header( ).
      lr_header_ctr->set_text( l_header ).
    set text header for Columns.
      CLEAR: l_header,lt_columns.
      lr_column_settings ?= wd_this->alv_config_table.
      lt_columns = lr_column_settings->get_columns( ).
      LOOP AT lt_columns INTO ls_column.
        CASE ls_column-id.
          WHEN 'PAYMENT_METHOD'.
    get header details
            lr_col_header = ls_column-r_column->get_header( ).
    disable DDIC field label
            CALL METHOD lr_col_header->set_prop_ddic_binding_field
              EXPORTING
                property = if_salv_wd_c_ddic_binding=>bind_prop_text
                value    = if_salv_wd_c_ddic_binding=>ddic_bind_none.
    set user defined column header
            l_header = wd_assist->if_wd_component_assistance~get_text( key = '020' ).
            lr_col_header->set_text( l_header ).
            CREATE OBJECT lr_drdn_by_key
              EXPORTING
                selected_key_fieldname = ls_column-id.
            ls_column-r_column->set_cell_editor( lr_drdn_by_key ).
            ls_column-r_column->se_width( '100PX' ).
            lr_drdn_by_key->set_key_visible(
              EXPORTING
                value = abap_true ).
          WHEN OTHERS.
        ENDCASE.
        CLEAR: l_header,ls_column.
      ENDLOOP.
    ENDMETHOD.
    Regards
    Manoj Kumar

  • How to show the VALUE as the Column Header using SQL query?

    Hi
    I have a requirement to show the picked value as the column header using SQL query.
    Example:
    ======
    SELECT EMPNO FROM EMP
    WHERE EMPNO=7934;
    Result Should be:
    7934
    7934

    I have a requirement to show the picked value as the column header using SQL query.In sql*plus you can do
    SQL> set verify on
    SQL> def e =  7934
    old: SELECT empno "&&e"  FROM emp  WHERE empno = &&e
    new: SELECT empno "7934"  FROM emp  WHERE empno = 7934
    SQL> SELECT empno "7934"  FROM emp  WHERE empno = 7934
          7934
          7934
    1 row selected.

  • I want to update the Custom table using the data available in ITAB.

    Hi,
    I want to updaste the Custom Table which is created by me (Ztable) using the data available in itab.(which i got from defferent standard tables)
    I want to update the custom table using the itab data How is it possible?
    Is any possible by using Modify ?
    DPK.

    example here
    modifying datbase table useing internal table
    advises before updating this datbase table plz lock that table to avoid incosistency
    write the logic for modifying
    Modify the database table as per new dunning procedure
    MODIFY fkkvkp FROM TABLE lt_fkkvkp .
    and finally unlock the table
    example
    *To lock table for further operations
    constants: lc_tabname TYPE rstable-tabname VALUE 'FKKVKP' . "FKKVKP
    CALL FUNCTION 'ENQUEUE_E_TABLE'
    EXPORTING
    tabname = lc_tabname
    EXCEPTIONS
    foreign_lock = 1
    system_failure = 2
    OTHERS = 3.
    IF sy-subrc EQ 0.
    To fetch all the contract accounts for customers of the segment
    Households/SME.
    PERFORM fetch_contract_accounts using lc_tabname .
    ENDIF. " IF sy-subrc EQ 0.
    *wrote the logic
    Modify the database table as per new dunning procedure from internal table
    MODIFY fkkvkp FROM TABLE lt_fkkvkp .
    *unlock the tbale
    CALL FUNCTION 'DEQUEUE_E_TABLE'
    EXPORTING
    TABNAME = uc_tabname .

  • My mac book air suddely disconnects many times the wifi while using wifi

    my mac book air suddely disconnects many times the wifi while using wifi

    Lots of things can impact wifi connections.  If you are at the marginal edge of the wifi range (which depends not only on distance, but what's between you and the transmitter) you may find the connection dropping in and out.  Sometimes a minor repositioning of the computer or transmitter can solve the issue.
    As well, interference can also create problems.  For instance, microwave ovens are really good at disrupting 2.4Ghz signals, and that the frequency used most often in wifi routers--so if someone turns on the microwave and it's between you and the transmission point it won't be surprising if the connection drops.  As well, metal blocks the signal fairly effectively, so if (say) ductwork is between the CPU and the wireless router there can be problems.
    Finally, I've run into some combos of devices and routers that just don't seem to like each other :-) .  That said, I've not hit that problem with either Air I'm running (an 11" and a 13"), though obviously I've not tried to connect them to every type of router out there.
    Just this week I was at a hotel and in my room the hotel wifi was "interesting" with every device I tried (iPhone, Android phone, Kindle Fire, iPad and the two Airs) dropping connection regularly from the work desk.  Turned out if I moved the devices over to the nightstand on the other end of the room (not the best work environment) all of the problems went away, so it clearly was a signal issue and the exact layout of that room and the hotel's wifi.
    If the machine has a problem when positioned close to a variety of routers, then I'd suspect a hardware issue with the wifi card in the Air and get that checked by Apple.  Similarly, if your problem is with your home router, I'd check to see if other devices also are getting dropped, since there could be a hardware issue on the router.

  • I can not connect to the internet while using my ipad I get a message saying Safari could not open the page because the server stopped responding need help thank you

    I CAN NOT CONNECT TO THE INTERNET WHILE USING MY IPAD I KEEP GETTING A MESSAGE SAYING SAFARI COULD NOT OPEN THE PAGE BECAUSE THE SERVER STOPPED RESPONDING PLEASE HELP THANK YOU

    Try the following:
    1. Turn router off for 30 seconds and on again
    2. Settings>General>Reset>Reset Network Settings
    3. Reset iPad; hold the Sleep and Home button down until you see the Apple Logo

  • I want to extract the Solaris media using "unpackmedia" option

    pack and unpack options operates on only miniroot archives and not on whole Solaris media.
    I want to extract the Solaris media using "unpackmedia" option.
    unpackmedia option of root_archive internally extract miniroots and additionally it extracts X.cpio.bz2 and pkg_db.cpio.bz2 based on some manipulations.
    man page of root_archive on solaris 11 still shows the information about these two removed options.
    Please let me know is there other way to achieve operations same as provided by unpackmedia option?
    Regards,
    Umesh

    When you intermix java/javascript code like this you have to realise the order in which this occurs.
    1 - all java code is executed - produces a static html
    2 - html is loaded, and javascript is run.
    So you can't run java code from an onClick event on the page.
    You have to submit a request (ie submit form/click link) to run java code, and it sends a response (new page) to the browser.
    So what you would end up with is code like this on your page
    Assuming you have three items in your list: {Item0, Item1, Item2} this will be the result:
    var z=0
    // for item0
    c.options[z]=new Option("Name0",Id0)
    z++
    c.options[z]=new Option("Name1",Id1)
    // for item1
    c.options[z]=new Option("Name0",Id0)
    z++
    c.options[z]=new Option("Name1",Id1)
    // for item2
    c.options[z]=new Option("Item0",Item0)
    z++
    c.options[z]=new Option("Item1",Item1)Suggestions as to what is wrong with this code
    1 - you only increment z once on each loop, but save two items.
    2 - you aren't using your counter 'I' in the get method.
    3 - you might need quotes around the values as well as the names.
    Personally, I think you're going the entire wrong way about this.
    Should you be using public static variable attributes? Are these values to be the same for every single user in the system?
    I would prefer to use a jsp scope (application scope if it is for all users) and just generate the html for the select right onto the page, rather than generating javascript to run and build the list.
    I would also use JSTL
    ie
    <select name="mySelect>
      <c:forEach var="asset" items="${assetList}">
        <option value="${asset.id}"><c:out value="${asset.name}"/>
      </c:forEach>
    </select>

  • I installed windows 7 using Boot camp, Then i wanted to install the support software using boot camp and it always stops at 50% i tried installing the software using internet it always gives me error when i start installing it on windows, What to do?

    I installed windows 7 using Boot camp, Then i wanted to install the support software using boot camp and it always stops at 50% i tried installing the software using internet it always gives me error when i start installing it on windows, What to do?

    What is the error? Are you following the Bootcamp instructions? Where on the "internet" are you trying to install from? Did you try downloading from here http://www.apple.com/support/bootcamp/downloads/?

  • I have a Numbers spreadsheet filled with data. I want to swop the columns

    I have a Numbers spreadsheet filled with data. I want to swop the columns to be rows & rows to be the columns, i.e make the columns the rows & make the rows the columns. Is there any way to do this? Thanks

    Here is a link to a previous discussion:
    https://discussions.apple.com/message/25571095#25571095
    SGIII provides and applescript

Maybe you are looking for

  • Can a Mini DisplayPort to Dual-Link DVI Adapter do the same job as the Mini DisplayPort to DVI Adapter?

    Can a Mini DisplayPort to Dual-Link DVI Adapter do the same job as the Mini DisplayPort to DVI Adapter?  Meaning, can I connect a DVI screen less than 30 inches?  Why would I buy the expensive product?  Simply because I might have to sometimes work w

  • Error while testing WEB UI

    Hi, I am trying to configure WEB UI. I have performed all the steps mentioned in C04 and steps mentioned by peter jacks thread. While testing the WEB UI. I am getting the following Error in my web page:: SSO logon not possible; invalid host name for

  • Re-downloads of music through iTunes app interrupts music on iPhone.

    When I go to download purchased music through the iTunes app, every time a song finishes downloading, the sound of music playing drops out for a second. Half the time the music stops playing all together and I have to go and re-hit play. The dropout

  • Multiple database in the same ADF application

    In my application I have to access a legacy database, in addition to the main database. How do I handle multiple database connections. Do I need to manage the JDBC connection to the legacy database myself. Pranab

  • Time Machine vs Backup

    I plan on reformatting my computer and would love to know if I should use Time Machine or Backup. I want to keep some of the programs and data from the computer, but not all of it. Which one will allow me to select data to "bring back"? Thanks for yo