How to : SELECT MAX(EmpID) / count(*) in SELECT Query

Hi,
I like to find out the Maximum of the EmpID that is in the DB table.
So I need to perform a select Query:
Select MAX(EmpID) from EmpTable
or Select Count(*) from EmpTable
<StatementName>
<dbTableName action=”SELECT”>
   <table>realDbTableName</table>
     <access>
         <??? />
      </access>
</dbTableName> 
</StatementName>
I cannot type MAX(EmpID) or count(*) as access element
So what should I mention in the Access?
Thanks & regards,
Siva Maranani.

if 0CALDAY is used as a characteristic then you have to convert that as a key figure using a replacement path variable.
Please see the below link for changing 0CALDAY as a key figure using Replacement path
http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
https://websmp106.sap-ag.de/~sapdownload/011000358700001963972003E/HowToCalcWithAttr.pdf
Now you have to create an exception "Top N Rows" based on the replacement path variable created above.
This will solve your problem.
Regs
Gopi.
Award points if it helps ...

Similar Messages

  • How the select Query Works

    Hi All
    I want to know how exactly the internal flow of select query works. Can someone please explain
    Thanks

    Hi,
    Thanks for the link.Is there any example for back end process of Select queryBingo.. ;)
    See, a process (or) set of programs which are working internally. You can get some of the results about the statistics of query how much cpu time it consuming, fetches etc., check v$sql_monitor. Apart from that if you are looking for some thing else then kindly elaborate your requirement.
    - Pavan Kumar N

  • How can I evaluate the count of a query I'd like to execute with a map...

    Hi. I have a problem with a query...
    I hava created a query which a execute with a Map (I use the
    executeWithMap(Map) method). The problem is that sometimes this query
    returns a large resultset. So, I would like to execute an other query
    (called query_count) before executing ther final query with the Map. If
    the query_count returns a count < 200, I execute the final query. How can
    I do ? There is an example I have read this in the documentation :
    Query query = pm.newQuery (Magazine.class, "price < 5");
    query.setResult ("count(this)");
    Long count = (Long) query.execute ();
    The problem in this example is that the query is not execute with a Map.
    So my question is : "How can we do the evalute the count of a query we
    would like to execute with a map ?". Thank you for any response.

    Hi John,
    You should be able to executeWithMap that query, too. Is that giving you
    problems?
    Note that there may be an easier solution. What do you do if there are more
    than 200 results? If, e.g., you just get the first N, then one option is to
    set the FetchBatchSize on the query to N (thus activating large result set
    support), and then call size () on the resulting Collection. This will
    issue a SELECT COUNT(*) to the database to determine the size automatically.
    Thanks,
    Greg
    "John" <[email protected]> wrote in message
    news:ctq9a8$4gr$[email protected]..
    >
    Hi. I have a problem with a query...
    I hava created a query which a execute with a Map (I use the
    executeWithMap(Map) method). The problem is that sometimes this query
    returns a large resultset. So, I would like to execute an other query
    (called query_count) before executing ther final query with the Map. If
    the query_count returns a count < 200, I execute the final query. How can
    I do ? There is an example I have read this in the documentation :
    Query query = pm.newQuery (Magazine.class, "price < 5");
    query.setResult ("count(this)");
    Long count = (Long) query.execute ();
    The problem in this example is that the query is not execute with a Map.
    So my question is : "How can we do the evalute the count of a query we
    would like to execute with a map ?". Thank you for any response.

  • How can I get record count with a query?

    In Client/Server pplication,the client send a query to server.
    How can server get record count by oracle call interface?
    Is it need execute "select count(*) from ...."?

    Yes.
    Either that or increment a counter for each record fetched and
    loop round until you hit the last record.
    The first method would be more efficient on large datasets.

  • How to return the record count of a query to a number variable

    How would I get the record count from a query without using a cursor to step through the query and count the records individually?
    query: select * from table1 where column1 = column2
    How would I get the record count of the query above?
    thanks,
    michelle

    I figured it out
    select count(*) into theCount
    from ( select * from table1 where column1=column2 );
    thanks,
    michelle

  • How to use MAX function in SSAS MDX Query

    I want to run this Query with MAX Condition on LAST_DATA_UPDATE Column .

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to output a row counter from sql query

    Here is an example of my problem. Say I have a table with 4 rows, my_table. Here is my select statement:
    select rownum,my_name,my_id
    from my_table
    order by my_name;
    What I need the output to be is something like this:
    1 Joe 22
    2 Carol 44
    3 Jim 21
    4 Jack 24
    What happens is that when I do the order by, the output is:
    2 Carol 44
    4 Jack 24
    3 Jim 21
    1 Joe 22
    What can I do to use the order by, but also have the counter in numerical order?

    Got two good hits on metalink:
    SELECT ROWNUM
    , t.my_name
    , t.my_id
    FROM (SELECT mt.my_name
    , mt.my_id
    FROM my_table mt
    ORDER BY mt.my_name) t
    AND ALSO THIS ONE:
    select rownum, a.*
    from
    select my_name,my_id
    from my_table
    order by my_name;
    ) a;

  • How to get max date field in the query

    Hi,
    We uploads the data into the cube every week.
    Basically we are planning to put some ticker on the query. This ticker will show the user, upto which date the data is available in the cube.
    I want the query, which will show me only the maximum date (maximum 0calday) from the infocube in the report.
    This in turn, I will use in the ticker and make use of it.
    Can anyone please help in making this query.
    Thanks
    Ramesh Ganji

    if 0CALDAY is used as a characteristic then you have to convert that as a key figure using a replacement path variable.
    Please see the below link for changing 0CALDAY as a key figure using Replacement path
    http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
    https://websmp106.sap-ag.de/~sapdownload/011000358700001963972003E/HowToCalcWithAttr.pdf
    Now you have to create an exception "Top N Rows" based on the replacement path variable created above.
    This will solve your problem.
    Regs
    Gopi.
    Award points if it helps ...

  • Getting a record count in a query using UNIQUE

    I need to know how to grab a record count for a query so I can pass it back into the recordset.
    This select query uses UNIQUE to rollup the 555 records to 125 unique rows.
    But how would I do a record count.
    Do I pass the query to a cursor and then count the records in the cursor?
    Please detail your help please.
    Thank you in advance.

    SELECT unique
         CE.DATE_OF_SERVICE AS DOS_FROM
         ,CE.SERVICE_END_DATE AS DOS_TO
         ,CE.EVENT_SERVICE AS SERVICE_TYPE
         ,CN.CREATE_DATE_TIME
         ,CN.CASE_NOTE_ID
         ,CN.CASE_ID
         ,CN.EVENT_ID
         ,CN.REASON
         ,CN.CREATOR_USER_ID AS CREATOR_ID_USED
         ,CN.ROWID AS ROW_ID
         ,(SELECT Retrieve_Note2(CN.CASE_ID,CN.CASE_NOTE_ID) from DUAL) AS NOTE
    FROM
         MEMBER_TO_PATIENT MTA,
         CARE_EVENT CE,
         CASE_NOTES CN
    WHERE
         MTA.SUBSCRIBER_LID = '1260016473015' AND
         MTA.CASE_ID = CN.CASE_ID AND
         CN.EVENT_ID = CE.EVENT_ID
    ORDER BY
         CN.CASE_NOTE_ID DESC

  • How to select a value of a max value of another column in the same row?

    pversion pdate pcount
    1     11/6/2011     1
    0     11/6/2011     25
    1     11/6/2011     24
    How to select pversion for a maximum pcount, in this case max count is 25 and version will be 0?

    Like this?
    -- Data:
    with yourtable as
    select 1 pversion , 1 pcount from dual union all
    select 0 , 25 from dual union all
    select 1 , 24 from dual
    -- Query:
    select max(pversion ) keep (dense_rank last order by pcount) m_pversion
    from yourtable;(When you want to use the query with your real data, you will have to change 'yourtable' to your actual tablename)

  • How to select the max rowid from a subquery with group by

    Hi Gurus,
    Kindly help how to fix the following query because I'm getting Oracle error:ORA-01446.
    select * from edy_raw_data a
    where rowid in ( select max(rowid) from(
    select email,max(date_updated) from edy_raw_data b
    where b.email=a.email
    group by email ))
    The query select the max rowid from a sub query with group by.
    Thanks in Advance.
    Benjie

    Why do you need to compare with rowid?
    Wouldn't this suffice?
    select * from edy_raw_data a
    where (email,date_updated) = (select email, max(date_updated) from edy_raw_data b
                        where b.email=a.email
                        group by b.email ))* Note: untested

  • How do you get  the count of number of  checkbox selected?

    hi,
    plz tell me how do you get the count of number of checkbox selected?

    Not sure what you are doing so I will attempt to answer your question. If have one question which can have multiple answers you have will recieve an array so you have to do getParameterValues("name") and move it into an array.
    If you have multiple questions and only value will be selected do a getParameter("name") on each form element.
    HTH, if not provide more detail.
    J.Clancey

  • How to Run a Select Query  stored in a Variable

    Hello,
    I have a following requirement:
    Result of one select query on Var1 , result of other select query in Var2 ,
    if Va2 = 'value11' OR Var2 = 'Value2' then Var1 = 'select query'. Now how can I run this SQL query at the end of the Pl/SQL?
    so I'm writing following query for the same:
    DECLARE
    qry nvarchar2(500);
    result nvarchar2(500);
    BEGIN
    select 'select TEXTVAL as "CHARG" FROM TABLE1 WHERE LOC =''[ParameterValue]'' and KEYNAME =''<<REPLACE>>''' INTO qry from dual;
    SELECT CASE WHEN count(RW."CountofBATCH") > 1 then 'Mixing'
    WHEN count(RW."CountofMAT") = 0 then 'None'
    ELSE 'Other'
    END
    INTO result
    FROM TABLENAME2 TT, XMLTable('/Rowsets/Rowset/Row' PASSING TT.XMLCOL
    COLUMNS
    "CountofBATCH" PATH '/Row[CLABS > 0]/CHARG',
    "CountofMAT" PATH '/Row[MATNR = "[Parameter Value]"]/MAT'
    ) AS RW
    where
    TT.PL = '[Parameter Value]' and
    TT.TANK = '[Parametr Value]' ;
    IF result = 'Mixing' OR result = 'None' THEN
    qry := replace( qry , '<<REPLACE>> ' , result);
    else
    qry := 'Nothing';
    END IF;
    This way the variable qry will have select statement. Now How can I run this qry variable to get the output of that select statement in the same query?

    you can use execute immediate if the output of the query is in the single query.
    that is very simple.
    have the query in the signle string and then pass like this
    declare
    qry varchar2(255);
    result varcharf2(2500);
    vempid number :=1;
    begin
    qry:='select empname from emp where empid=:empid';
    execute immediate qry into result using vempid;
    -----now the data result is in result
    end;

  • How to get number of rows return in SELECT query

    i'm very new in java, i have a question:
    - How to get number of rows return in SELECT query?
    (i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)
    Thanks.

    make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
             String sql = "select * from testing";
             PreparedStatement ps =
              con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
             ResultSet rs = ps.executeQuery();
             rs.last();
             System.out.println("Row count = " + rs.getRow());
             rs.beforeFirst();~Tim
    NOTE: Ugly, but does the trick.

  • How to Select each check box values in a group of records

    Hi,
    I have a requirement in forms 10g. In that form there are 10 records are displaying each record has one check box is there if i click the check box on record number one and record number three and do some changes in the text field(adjustment field is number data type) then finally I want to see the total on one field called total amount.
    In this my question is how to select particular records in a group of records? and finally these selected records are inserted into one table.
    Because I am not able to fetch these records at a time.
    Is there any Array to define a record group to fetch each of them individually for example Rec[1],Rec[2]...like that if yes please suggest me the steps how to do this.
    Thanks in advance
    Prasanna
    Edited by: user10315107 on Dec 17, 2008 11:44 PM

    I'm sorry, but i didn't get your requirement in detail.
    Do you want to do the summing of the selected records in forms ? Or do you just want to know which records are selected and then process them?
    If you want to process the selected records in sql you could use an object-type to store the list of id's (of whatever primary key you use), loop over the block to fill it, and then afterwards process them.
    For this approach, first create an object-type in the database:
    CREATE OR REPLACE TYPE ID_LIST AS TABLE OF NUMBER;
    /Then, in forms you could do something like this to fill a list of id's:
    DECLARE
      lIds ID_LIST:=ID_LIST();
    BEGIN
      GO_BLOCK('MYBLOCK');
      FIRST_RECORD;
      LOOP
        EXIT WHEN :SYSTEM.RECORD_STATUS='NEW';
        IF :BLOCK.CHECKBOXITEM="CHECKEDVALUE" THEN
          lIds.EXTEND(1);
          lIds(lIds.COUNT):=:BLOCK.PRIMARYKEYITEM;
        END IF;
        EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
        NEXT_RECORD;
      END LOOP;
      -- Now you can use the object-list in SQL like :
      INSERT INTO MYNEWTABLE (cols..)
      SELECT (cols..)
        FROM MYOLDTABLE
       WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(lIds));
    END;Edited by: Andreas Weiden on 18.12.2008 18:17

Maybe you are looking for

  • My iTouch is not recognized by my computer.

    I've been trying to sync my 1st generation iTouch to my Dell Inspiron (I think it's a e1705) laptop for awhile. Originally, I was able to plug in my iPod without any problem and connect it to iTunes. However, in the middle of while I was syncing, the

  • Unable to update 5.0.1 or 6.0.1 Download spins indefinitely using OSX10.6.8

    I have been unable to update the 2 latest versions of Firefox. I'm using OSX 10.6.8 I get a warning that one of my add-ons (Contribute) is not compatible and will not appear on my menu bar. Then the download scroll just spins and spins.

  • How to solve this problem"exception in thread "main" java.lang.noclassdeff"

    I am a tyro of java programming . i downloaded the j2sdk-1_4_2_09-windows-i586-p.exe from www.java.sun.com and installed it at the defaulted path C:\j2sdk1.4.2_09, then i wrote down my first java program as follow: public class hello public static vo

  • Script code not working online (Bridge gallery to Dreamweaver)

    Hi there I'm a newbie, so please pardon my amateur problem.  I am doing a website as a favor for someone and have always worked with FrontPage.  DW is totally new to me. I've created a photo gallery using Bridge and then opened up the index.html (the

  • Authorization Role Practice in Implementation Project

    Gurus, Okay, I've been implementing SAP R/3 for around 5 implementation cycles, before realizing my method for creating role may be outdated. I need your advice regarding this. Here's my common scenario on every implementation project in realization