Counting only some rows without where or subqueries?

Is it possible with oracle to count only some of the rows? I mean without excluding the rows in where or using sub queries.
This does not work but I think it illustrates what I want:
SELECT count(flags), count(flags like '%P%'), count(flags like '%F%') FROM table WHERE some_column = 2;
Where the first would return the number of flags rows, while the second contet the numbers that have P in them and the third counted the number with F.
Table would be
Flags Some_column
'AFP' 2
'A* 1
'PF' 1
'P' 2
And so on.
In postgres you can do: count(substring(flags from 'R')), to achieve the above mentioned idea. Does oracle have a way of doing the same?

Your requirement is not clear. But.. Is this what you are trying to achieve?
SQL> with t
  2  as
  3  (select 'AFP' st from dual
  4  union all
  5  select 'A*' from dual
  6  union all
  7  select 'PF'  from dual
  8  union all
  9  select 'P'  from dual
10  )
11  select sum(1) sum1,
12  sum(case when st like '%P%' then 1 else 0 end) sum2,
13  sum(case when st like '%F%' then 1 else 0 end) sum3
14  from t
15  /
      SUM1       SUM2       SUM3
         4          3          2

Similar Messages

  • Bought a TV season and only some episodes downloaded where remaining had "download error" on iPad 1

    Bought a TV season and only some episodes downloaded where remaining had "download error" on iPad 1? Tried many times for few days with no use. Tried restarting too. Device has enough memory too!

    Because of the error message, I'm not sure if any of this will work, but I suppose it's worth a shot.
    Sign out of your account, restart the iPad and then sign in again.
    Settings>Store>Apple ID. Tap your ID and sign out. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Go back to Settings>Store>Sign in and then try to resume the downloads.
    If the TV shows appear at all in the videos app - did you try tapping and holding down on the icons to see if the X to delete pops up? Is there any evidence of the stalled downloads on the iPad in the videos app? If you could delte them, you might be able to resume the downloads.
    If you live in the U.S., Canada, The UK or Australia, TV shows can be downloaded again at no charge as long as you use the same Apple ID.

  • How to edit only some rows in ALV

    Hi Experts,
    I have editable ALV. I need to allow edit only for some rows, not generaly all of them.
    Do you have any idea how to do it?
    I use ALV through FM module REUSE_ALV_GRID_DISPLAY.
    Thenks&regards,
    Jirka

    Hi,
    You need to use events. Sample code from sdn.
    TYPE-POOLS:SLIS.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:IT_EVENTS TYPE SLIS_T_EVENT.
    data: begin of it_chg occurs 0,
          index type sy-tabix,
          end of it_chg.
    DATA:  X_EVENTS    TYPE SLIS_ALV_EVENT.
    DATA: BEGIN OF ITAB OCCURS 0,
          NAME(10) TYPE C,
          ZTERM TYPE C,
          END OF ITAB.
    PERFORM FILL_TABLE.
    loop at itab where zterm = 'A'.
    it_chg-index = sy-tabix + 3. 
    " addition 3 IS FOR FIELD LABELS
    append it_chg.
    clear it_chg.
    endloop.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    **fieldcatalog
    X_FIELDCAT-FIELDNAME = 'NAME'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-FIELDNAME = 'ZTERM'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    **events
    REFRESH:IT_EVENTS.
    CLEAR:X_EVENTS,IT_EVENTS.
    X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
    X_EVENTS-FORM = 'MODIFY_LIST'.
    APPEND X_EVENTS TO IT_EVENTS.
    CLEAR X_EVENTS.
    END-OF-SELECTION.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = SY-REPID
          IT_FIELDCAT        = IT_FIELDCAT
          IT_EVENTS          = IT_EVENTS
        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 FILL_TABLE
          text
    FORM FILL_TABLE.
      ITAB-NAME = 'vijay'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ABC'.
      ITAB-ZTERM = 'B'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'TEST'.
      ITAB-ZTERM = 'C'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'DILIP'.
      ITAB-ZTERM = 'D'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = '123'.
      ITAB-ZTERM = 'E'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'GEN'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALV'.
      ITAB-ZTERM = 'F'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALVTEST'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
    ENDFORM.                    "FILL_TABLE
    *&      Form  MODIFY_LIST
          text
    FORM MODIFY_LIST.
    data: l_lines type i.
    describe table itab lines l_lines.
      L_LINES  = L_LINES + 3.
      "because we have 3 lines extra occupied by lables.
      "if we have header,i mean top of page add the no.of lines
      "how many ever top of page have + 3 for labels.
      DO L_LINES TIMES.
        read table it_chg with key INDEX = sy-index.
        if sy-subrc = 0.
    **This code is for reading the out put line
    **and modify accordinlg to our requiremnet.
    **don't chnage this.
          READ LINE SY-INDEX INDEX SY-LSIND.
          IF SY-SUBRC = 0.
            MODIFY LINE SY-INDEX INDEX SY-LSIND
                       FIELD FORMAT ITAB-NAME INPUT.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    "MODIFY_LIST

  • Restricting rights to modify only some rows

    Hi,
    I just discovered HTML DB and played around with it on myhtmldb.com because htmldb.oracle.com is down for some reason.
    Is there a way to restrict write access to some rows of a table for each user? For example everybody can see the whole table but you can only add/delete/modify the rows where your id/company name/.. is present in one column.
    Cheers
    Mathias

    Hi,
    I just discovered HTML DB and played around with it
    on myhtmldb.com because htmldb.oracle.com is down for
    some reason.
    Is there a way to restrict write access to some rows
    of a table for each user? For example everybody can
    see the whole table but you can only
    add/delete/modify the rows where your id/company
    name/.. is present in one column.
    Cheers
    Mathias

  • Download link for only some rows

    Hi,
    I have 2 tables. One contains records for products, and the other contains images for only some of the products. The images have been uploaded through the application and therefore are in a 'upload_data' table.
    The tables are linked by product_id.
    I would like to display a report that shows all the column from the products table and a download link for only those products that have an image.
    So far the query only returns those rows that have an image.
    Thanks
    Edited by: user12970007 on 20-Apr-2010 17:59

    What does this query look like?

  • Only some rows selectable

    Hi,
    I wonder if anybody could help me in my problem?
    I made a table and would like only some of the rows to be selectable. Is this possible?
    The best solution would be to hide those squares on the left of the rows.
    Thanks in advance for your help.
    Piotrek
    Edited by: Piotr Kondratowicz on Feb 10, 2009 4:29 PM

    Hi Piotr,
    Create a value attribute of type boolean(Ex: ed) and assign it to all editable fields of the table.
    Based on a condition enable(ed=true)/disable(ed=false) the row fields as read only.Which will fulfill your requirement.
    Thanks & Regards,
    Jhansi Miryala

  • ALV - how to make selectable only some rows on an ALV?

    Hi my problem is:
    I have an ALV GRID as output of a report.
    I have to make selectable only few rows based on the contents of a field (showed in a column in the ALV).
    Is it possible?
    Best Regards, Vincenzo

    I did understand, but as i told you there is nothing like that, neither an option nor an event to capture.
    Here is the documentation: http://help.sap.com/saphelp_erp2005vp/helpdata/EN/bf/3bd1369f2d280ee10000009b38f889/frameset.htm
    Read it and choose what you need and what is in existance.

  • Select only some rows

    Hi all,
    I've a query with more than 500 rows as result. I'm only interested to show the first 50 rows. Did you know any way to prepare the select sentence to do it? I prefer avoid use cursors to do that.
    Regards,
    dbajug

    Hitesh Nirkhey wrote:
    hi
    use ROWNUM keyword for fetching first 50 rows
    simplest example
    select * from emp
    where rownum < 5 ;
    regards
    HiteshROWNUM applies to the rows after they are collected into a result set. Thus, it may, or may not, fulfill the OP's requirements. He still needs to define what he means by "first 5 rows".
    http://psoug.org/reference/pseudocols.html
    Also see description of ROWNUM in the fine SQL Reference manual

  • Make only some rows in a report  as links

    Hi friends,
    I am trying to make some of the rows in a report(The report is using union to take data from multiple tables) as links. For example i am trying to make a row corresponding to "emp" as a link. For this i am trying to use the below code
    select dname "c1" from dept where dname='dept5'
    union all
    select
    '<a href=*"javascript:popUp2('
                      || '''f?p=&APP_ID.:4:&SESSION.::&DEBUG.::'
                      || 'P3_EXAMPLE:'
                      || ename
                      || ''', 700, 500);'
                      || '" >'
                      || ename*
                      || '</a>'
    "c1" from emp where Empno=7839
    --remove the '*' from the codeBut i a getting the result as
    dept5
    <*a href="javascript:popUp2('f?p=19669:4:1768622885363834::NO::P3_EXAMPLE:KING', 700, 500);" >KING</a*>
    --remove the '*'
    What i need to use to make this row a link.
    Thanks,
    Jeev

    Ensure that the Display As Column Attribute for the report column is Standard Report Column.

  • Display item renderer in only some rows of a datagrid

    I need to display a combobox item renderer in my datagrid
    only in the first of every 5 rows. With the remaining 4 rows in
    this particular column empty. Then the pattern will repeat again.
    This is how I am currently creating the columns however with
    this approach the combobox itemrenderer is appearing in all rows
    <mx:columns>
    <mx:DataGridColumn headerText="No."
    dataField="assCriteriaNum" width="60" />
    <mx:DataGridColumn headerText="Assessment Criteria"
    dataField="assCriteria" width="210"/>
    <mx:DataGridColumn headerText="Mark Range"
    dataField="markRange" width="50" />
    <mx:DataGridColumn headerText="Mark" dataField="mark"
    width="70" >
    <mx:itemRenderer>
    <mx:Component>
    <mx:ComboBox>
    <mx:dataProvider>
    <mx:ArrayCollection>
    <mx:String>0</mx:String>
    <mx:String>1</mx:String>
    <mx:String>2</mx:String>
    <mx:String>3</mx:String>
    <mx:String>4</mx:String>
    <mx:String>5</mx:String>
    <mx:String>6</mx:String>
    <mx:String>7</mx:String>
    <mx:String>8</mx:String>
    <mx:String>9</mx:String>
    <mx:String>10</mx:String>
    </mx:ArrayCollection>
    </mx:dataProvider>
    </mx:ComboBox>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    </mx:columns>

    Here is my data provider hard coded
    <mx:dataProvider>
    <mx:ArrayCollection>
    <mx:Array>
    <mx:Object assCriteria="A01 Manage." />
    <mx:Object assCriteriaNum="1" assCriteria="Brief project
    plan, with little evidence of monitoring progress of project work
    against the project plan." markRange="(1-3)" />
    <mx:Object assCriteriaNum="2" assCriteria="Limited
    identification of the topic to be investigated/ researched and
    limited evidence of appropriate aims and objectives, and proposed
    project title." markRange="(1-3)" />
    <mx:Object assCriteriaNum="3" assCriteria="Project plan,
    with some evidence of monitoring progress of project work against
    the project plan." markRange="(4-6)" />
    <mx:Object assCriteriaNum="4" assCriteria="Some
    identification of the topic to be investigated/ researched and some
    evidence of appropriate aims complete the work and objectives, and
    proposed project title." markRange="(4-6)" />
    <mx:Object assCriteriaNum="5" assCriteria="Detailed
    project plan, with clear evidence of monitoring progress of project
    work against the project plan." markRange="(7-10)" />
    <mx:Object assCriteriaNum="6" assCriteria="Clear
    identification of the topic to be investigated/ researched and
    clear evidence of appropriate aims identify the topic and
    objectives, and proposed project title." markRange="(7-10)" />
    <mx:Object assCriteriaNum="7" assCriteria="No relevant
    response." markRange="(0)" />
    <mx:Object assCriteria="A02 Use resources/research."
    />
    <mx:Object assCriteriaNum="8" assCriteria="Little or no
    analysis and application of the research, with few links made to
    appropriate theories and concepts." markRange="(1-5)" />
    <mx:Object assCriteriaNum="9" assCriteria="Evidence of
    limited research involving limited selection and evaluation of
    sources." markRange="(1-5)" />
    <mx:Object assCriteriaNum="10" assCriteria="Some analysis
    and application of the research, with links made to appropriate
    theories and concepts." markRange="(4-6)" />
    <mx:Object assCriteriaNum="11" assCriteria="Evidence of
    some research involving the selection analyse data and evaluation
    of a range of relevant sources." markRange="(4-6)" />
    <mx:Object assCriteriaNum="12" assCriteria="Critical
    analysis and application of the research, with obtain and select
    clear links made to appropriate theories and information from a
    concepts. variety of sources." markRange="(7-10)" />
    <mx:Object assCriteriaNum="13" assCriteria="Evidence of
    detailed research involving the selection and evaluation of a wide
    range of relevant sources." markRange="(7-10)" />
    <mx:Object assCriteriaNum="14" assCriteria="No relevant
    response." markRange="(0)" />
    </mx:Array>
    </mx:ArrayCollection>
    </mx:dataProvider>

  • Hotspot click for only some rows in ALV grid for a particular column ?

    Hi there,
            In ALV grid, we can make Hotspot enable for all rows in a specified column
    by specifying in the fieldcatalog with Hotspot attribute set as true.
    But I want to enable Hotspot only for certain rows in the particular column. I tried with MC_STYLE4_LINK , but I didnt got the required result.
    So , how could I achieve that in ALV grid.
    Points would be rewarded for helpful answers.
    Regards,
    Anil .

    Hi,
    You can do it for a column. Please refer to the code snippet below,
      DATA : it_fcat TYPE lvc_t_fcat,
             wa_fcat LIKE LINE OF it_fcat.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
      I_BUFFER_ACTIVE              =
         i_structure_name             = 'SMMW_ALERTS_ICON_S'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = it_fcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
    LOOP AT it_fcat INTO wa_fcat.
      IF wa_fcat-fieldname = 'STATUS'.
        wa_fcat-hotspot = 'X'.
        MODIFY it_fcat FROM wa_fcat.
        CLEAR wa_fcat.
      ENDIF.
    ENDLOOP.
    CALL METHOD l_obj_alv_grid->set_table_for_first_display
          EXPORTING
        i_structure_name              = 'SMMW_ALERTS_ICON_S'
       CHANGING
            it_outtab                     = lt_alerts_st
            it_fieldcatalog               = it_fcat.
    In the above replace the structure 'SMMW_ALERTS_ICON_S' with your structure and column 'STATUS' with your desired column.
    Hope this helps,
    Regards,
    Vinodh

  • One to many to return only one row

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

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

  • Get only the rows where there are no matches in the tables

    To include in the results of a join with no matching rows, you can use a full outer join. In MS SQL Server provides the FULL OUTER JOIN operator, which allows you to include all rows from both tables, regardless of the presence or absence of values.
    You can add a WHERE clause in a FULL OUTER JOIN to get only the rows where there are no matches in the tables. The following query returns only those products for which there are no matches in the sales order.
    SELECT p1.Name, p2.SalesOrderID
    FROM  TAB1 p1
    FULL OUTER JOIN TAB2 p2
    ON p1.ProductID = p2.ProductID
    WHERE p1.ProductID IS NULL
    ORDER BY p.Name ;
    FULL OUTER JOIN is not supported in ABAP.  How can you solve this?
    Thanks in advance,
    Serena

    Similar problems can often be solved by using subqueries, please have a look here and try applying it.
    http://help.sap.com/abapdocu_702/en/abenwhere_logexp_subquery.htm
    Thomas

  • HT201077 I am a new iphone 5 user and set it up to use icloud to store pictures, etc. I set up my home computer afterwards, but only some pictures are on the icloud. How do I view the rest of my pictures on my  home computer? Where are they stored?

    Only some of my pictures are on iCloud that are currently stored on my phone. Where are the others? Why aren't all the pictures from my iPhone showing in the iCloud? I can't find the pictures I saved from my ipodtouch, either....

    Only some of my pictures are on iCloud that are currently stored on my phone. Where are the others? Why aren't all the pictures from my iPhone showing in the iCloud? I can't find the pictures I saved from my ipodtouch, either....

  • Count the no.of rows without using count function

    Hi,
    How to count the no.of rows without using the count function?
    Thanks,

    they won't be 100% accurate. You're correct, Bluefrog, but the same goes for doing a count(*) (depending on the size of the table, ofcourse):
    the table being queried might be under DML (deletes/inserts), and the next count(*) might give different results.
    Both approaches will never be 100% accurate.
    But simply selecting num_rows will be much much faster than doing a count(*).
    Counting the number of rows always reminds me of this ongoing discussion, by the way:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:127412348064#14136093079164 ;)
    Usually knowing the number of records by approximatly is sufficient, imo. 1000000 or 1000007 records: I don't care, don't need to know that.
    I've never needed to know the exact number of records in a table in my code, or been given a requirement that forced me to.

Maybe you are looking for

  • Not just another file sharing thread......

    Running a forum search gives me a plethora of file sharing threads. Most of these threads are a one answer type of question or a simple "Preferences>Sharing>File Sharing type of answer. I am no expert here, I learn something every time I visit, but I

  • Photoshop Elements 11 download problem

    I cannot reload Photoshop and Premier Elements 11 (after pc wipe clean) as it asks me to close dynamiclinkmanager.exe. I cannot find a file to close or delete only a folder with nothing to use. What do I do please?

  • RFC - XI - File

    Hello, I have a scenario where I must create a flat file from data in the SAP. I created a report that prepares the data and the calls RFC on destination 'XI' with the data. This works and the file gets created but I am getting errors on the XI log.

  • Self-made link for "Customize page" ?

    How do I add a link in a Navigaion Bar that does the same as the built-in "Customize page" link in the built-in header ? Is there any procedure for that purpose? (the link seams to not use a procedure)

  • Limit Inserted rows

    Hello, i need/want a SQL in my ETL-Process (building a DWH) that find data sets in the fact table which have no reference to the dimension table. These incorrect data sets should be inserted in an error table. insert into ERROR_TABLE SELECT distinct(