Jslt +sql count

Hi,
i would be thanksfull fi anyone would tell me, how to get the value from the count sql-statement using jstl..
the tags should look sth like this:
<sql:query var="getUser" >
SELECT COUNT(Row) FROM table
</sql:query>
<c:set var="count" value="${getUser}" scope="page" />
but sth is wrong. for any suggestion thanks!

ive solve this in that way..
<sql:query var="getUser" >
SELECT COUNT(Row) AS cnt FROM table
</sql:query>
<c:forEach var="Temp" begin="0" end="1" items="${getUser.rows}">
<c:set var="users" value="${Temp.cnt}" scope="session" />
</c:forEach>
but if there is any way to set the variable users in some way with using only one tag?

Similar Messages

  • Perform SQL COUNT from AS3

    Hi there all,
    Just working away as usual and I've encountered a problem with a flash app I'm making..
    I can save and load variables from flash to the mySQL database, but when I load up the results one after the other I eventually run out of results to display, which throws an error !!
    Is there a way I can perform an SQL COUNT from flash to determine the amount of results I have in the database and loop the viewer back to the first result ??
    Many Thanks in advance for any help

    This is how I am parsing and requesting the information.. I know it's in there somewhere I just can't get the variables, do I need to add them ? It's not making much sense to me at the moment, I'm sorry !! I need to add the variables to the request somehow.. so I can receive the info, no ?
    var tab = "SQLtab";
    var filesend = "path to php file";
    var modesend = "post";
    function variableTransaction(fichier, modesend, tab, var1, var2) {
         var URLload = new URLLoader();
         var URLrequest = new URLRequest(fichier);
         var variables:URLVariables = new URLVariables();
         variables.tab = tab;
         variables.var1 = var1;
         variables.var2 = var2;
         if (modesend == "post") {
              URLrequest.method = URLRequestMethod.POST;
         } else if ( modesend == "get") {
              URLrequest.method = URLRequestMethod.GET;
         if (var1 == false && var2 == false) {
              URLload.dataFormat = URLLoaderDataFormat.VARIABLES;
              URLrequest.data = variables;
              URLload.load(URLrequest);
              URLload.addEventListener(Event.COMPLETE, loadComplete, false, 0, true);
         } else {
              URLrequest.data = variables;
              URLload.load(URLrequest);
              var receiveObject = variableTransaction(filesend, modesend, tab, false, false);

  • Sql count function in order by clause

    Post Author: krypton
    CA Forum: Data Connectivity and SQL
    Hi Guys
    Can i ask a quick question. I am trying to retrieve data remotely from a SQL Server via crystal reports.
    Within the Database Expert I have entered a SQL query to retrive the number of (call center) support calls raised by our customers:-
    Select `Primary_Company`, COUNT(`Calls`)From  `SPRT_Issue` GROUP BY  `Primary_Company`ORDER BY  COUNT(`Calls`) desc
    The customer's column is called 'Primary Company' and the calls they raise are in the 'Calls' column. the above is a normal sql query.
    However Crystal fails to run the query and generates an error message :-
    Failed to open a rowset. Details: 420: Driver&#93; Expected lexical element not found: <identifier>
    I dont understand why it wont run. In the ORDER BY clause if i replace field 'Calls' by the field 'Primary Company' then it works.
    I think the problem is that it wont accept the count function in the order by clause. which is what i want it to do i.e display the calls in descending order by each customer.
    Could someone tell me if there is a way around it.
    Thanks
    Krypton

    Post Author: krypton
    CA Forum: Data Connectivity and SQL
    Thanks Lynn
    I tried your suggestion. But there is one probelm.
    When i sort the data in descending order using the count(calls) field, the data is returned but the customer's name appears multiple times along with their calls raised.
    E.g, if customer Mark raised multiple calls i.e. 2, 5, and 10 calls, then the report will show
    Mark   2
    Mark  5
    Mark 10
    But is there a way to aggregate all the calls for mark and show them only once:
    such as Mark   17
    Thanks

  • SQL MAX QUERY / SQL COUNT QUERY

    Hi all,
    i would like to get the value of the number of rows i have, but i dun seem to work it out with the getRow statements. i think the syntax of my statement is ok, but maybe i am doing the wrong way to get the value out.
    I tried with COUNT, and it gives me the same error.
    The error is: java.sql.SQLException: Column not found
    This is the part of my code
    Connection con;
    String Q;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:RFID Logistics");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT MAX(Queue) FROM Forklift1");
    while(rs.next())
                        Q = rs.getString("Queue");
                        System.out.println(Q);
              catch(ClassNotFoundException f)
                   f.printStackTrace();
              catch(SQLException f)
                   f.printStackTrace();
    Thx alot in advance =)

    Please use code tags when posting code. There is a code button above the message editor that inserts the tags.
    Do you want to get the number of rows? If soConnection con;
    int num = 0;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:RFID Logistics");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM Forklift1");
    while(rs.next())
    num = rs.getInt(1);
    System.out.println(num );
    rs.close();
    stmt.close();
    catch(ClassNotFoundException f)
    f.printStackTrace();
    catch(SQLException f)
    f.printStackTrace();
    }This is untested, but should be close enough.

  • PL/SQL - counting values' occurences in a collection - how to optimize?

    Hi all,
    I'm new here and working currently on my PhD thesis, using Oracle (XE) to do some data manipulation stuff.
    Following is defined:
    TYPE stat_col_type IS TABLE OF INTEGER;
    rows_lens stat_col_type;
    Using MULTISET UNION operations, I get the final rows_lens as a set of values, e.g. {1,2,3,1,1,2,2,2,3,3,3,3,3,3,3,1,1,2,1,1,4,5,6,2,2,2,3,3}.
    What I need is to count the occurences of the unique values :
    value of 1 : 7 occurences
    value of 2 : 8 occurences
    value of 3 : 10 occurences
    value of 4 : 1 occurence
    value of 5 : 1 occurence
    value of 6 : 1 occurence
    Ideally, the result should be a separate collection where the values become indexes (there are numbers, natural, unique and countable) and the number of occurences - their values :
    output_col( value ) := number-of-occurences ;
    Of course, I could just go through all the elements incrementing the counters in the output collection, but surely there must be a most efficient way - probably using POWERMULTISET or some kind of SUBSETS. As haven't been using /developing in/ Oracle for a longer period... it's better to ask :)
    Thanks in advance for your suggestions.
    Regards,
    Bart
    Edited by: user3698166 on 2010-01-16 13:44

    What I need is to count the occurences of the unique values :
    Following is defined:Why don't you define in PLSQL and not in SQL?
    It would be so much easier:
    SQL> create type stat_col_type as table of integer
    Type created.
    SQL> select column_value, count (column_value) cnt
      from table (
              stat_col_type (1,
                              2,
                              3,
                              1,
                              1,
                              2,
                              2,
                              2,
                              3,
                              3,
                              3,
                              3,
                              3,
                              3,
                              3,
                              1,
                              1,
                              2,
                              1,
                              1,
                              4,
                              5,
                              6,
                              2,
                              2,
                              2,
                              3,
                              3
    group by column_value
    order by column_value
    COLUMN_VALUE        CNT
               1          7
               2          8
               3         10
               4          1
               5          1
               6          1
    6 rows selected.
    SQL> drop type stat_col_type
    Type dropped.

  • PL/SQL Counter for HTMLDB - Application Express - Survey Counter

    I wonder if somebody could help me to clarify the HowTo on this Survey.
    Based on:
    http://www.oracle.com/technology/products/database/application_express/index.html
    http://www.oracle.com/technology/oramag/oracle/06-mar/o26browser.html
    I follow up however that is not exactly what I like to see in my Survey. I like to make something more elegant and flexible.
    On this example he put 10 questions/ page. I like to use 1 Question / Page.
    And I like to extend to more than 10 pages. for example 20.
    My question to the forums is:
    If I create an application with Only 3 pages [ Welcome, Survey, End ]
    And the main page for the Survey is the second page.
    How would programatically be the logic to:
    Start the Welcome page => Setup variable counter = 1
    Then using sessions with a button click on Start Survey.
    Survey Page check for the existence of counter variable if exist retrieve the Question from the Questions table and the properly Answer will be recorded.
    This answer could include comments, and the Rating could be an LOV.
    After the Question 1 is asnwered then the Next Button on the Page 2 Call the same page 2. If the Questions is the max number of questions [20] then go to the End or Summary Page. if not just increase the counter variable then retrieve the next question.
    Am I asking to much ???. I'm just starting on PL/SQL and HTMLDB I'm not sure how to manipulate those variables. I've been trying but I'm stuck.
    Thanks in Advance for your Help.
    Dino.
    http://htmldb.oracle.com/pls/otn/f?p=42721:1:4875344191023058749:::::
    PS -> As soon as have the answer will post it public in htmldb.oracle.com =)

    Move this over to :
    Oracle Application Express (APEX)

  • Sql Count Help

    Hi Everyone,
    I need to display SPER_STATUS_TEXT count as 0 if there is no data for below Query. Could someone please help me
    SQL> SELECT a.sper_status_text, COUNT ( * )
    2 FROM (SELECT sper.assettxt,
    3 CASE
    4 WHEN sper.sper_status_text = 'Affirmed Evaluation'
    5 THEN
    6 'Affirmed Evaluation'
    7 WHEN sper.sper_status_text LIKE 'Updated - Evaluated Up%'
    8 THEN
    9 'Updated - Evaluated Up'
    10 WHEN sper.sper_status_text LIKE 'Updated - Evaluated Down%'
    11 THEN
    12 'Updated - Evaluated Down'
    13 ELSE
    14 'Other Responses'
    15 END
    16 sper_status_text
    17 FROM zzcus.zzcus_sper_data sper
    18 WHERE sper.sper_dates = '20100801--20100831'
    19 AND sper.customer_id = 'NATFINS'
    20 AND sper.task_inquiry_type = 'Vendor Comparison'
    21 AND sper.assettxt <> '!NA'
    22 ) a
    23 GROUP BY a.sper_status_text
    24 ORDER BY (CASE
    25 WHEN a.sper_status_text = 'Affirmed Evaluation' THEN 1
    26 WHEN a.sper_status_text = 'Updated - Evaluated Up' THEN 2
    27 WHEN a.sper_status_text = 'Updated - Evaluated Down' THEN 3
    28 ELSE 4
    29 END);
    Results:
    SPER_STATUS_TEXT COUNT(*)
    Affirmed Evaluation 2
    I need to display like below (if there is no data I need to display count as 0)
    SPER_STATUS_TEXT COUNT(*)
    Affirmed Evaluation 2
    Updated - Evaluated Up 0
    Updated - Evaluated Down 0
    Other Responses 0
    Please Advice

    You can get it like this. By using MODEL clause,
    SQL>
    SQL> CREATE TABLE ZZCUS_SPER_DATA1
      2  (
      3     SPER_STATUS_TEXT VARCHAR2 (30)
      4    ,TASK_INQUIRY_TYPE VARCHAR2 (100)
      5  );
    Table created.
    SQL>
    SQL> INSERT INTO ZZCUS_SPER_DATA1
      2       VALUES (
      3                 'Data Updated', 'Descriptive Data Challenge - Maturity date / Redemption date');
    1 row created.
    SQL>
    SQL> INSERT INTO ZZCUS_SPER_DATA1
      2       VALUES ('Data Updated', 'Descriptive Data Challenge - Ticker / Local Code');
    1 row created.
    SQL>
    SQL> SELECT *
      2    FROM (  SELECT A.SPER_STATUS_TEXT, COUNT (*) CNT
      3              FROM (SELECT CASE
      4                              WHEN SPER.SPER_STATUS_TEXT = 'Data Confirmed'
      5                              THEN
      6                                 'Data Item Confirmed'
      7                              WHEN SPER.SPER_STATUS_TEXT LIKE 'Data Updated'
      8                              THEN
      9                                 'Data Item Updated'
    10                              ELSE
    11                                 'Other Responses'
    12                           END
    13                              SPER_STATUS_TEXT
    14                      FROM ZZCUS_SPER_DATA1 SPER
    15                     WHERE 1 = 1
    16                           AND SPER.TASK_INQUIRY_TYPE LIKE 'Descriptive Data Challenge%') A
    17          GROUP BY A.SPER_STATUS_TEXT
    18          ORDER BY (CASE
    19                       WHEN A.SPER_STATUS_TEXT = 'Data Item Confirmed' THEN 1
    20                       WHEN A.SPER_STATUS_TEXT = 'Data Item Updated' THEN 2
    21                       WHEN A.SPER_STATUS_TEXT = 'Other Responses' THEN 3
    22                       ELSE 4
    23                    END))
    24  MODEL
    25     DIMENSION BY (SPER_STATUS_TEXT)
    26     MEASURES (CNT)
    27     RULES
    28        (CNT ['Data Item Confirmed'] = NVL (CNT[CV ()], 0),
    29        CNT ['Data Item Updated'] = NVL (CNT[CV ()], 0),
    30        CNT ['Other Responses'] = NVL (CNT[CV ()], 0));
    SPER_STATUS_TEXT           CNT
    Data Item Updated            2
    Other Responses              0
    Data Item Confirmed          0
    3 rows selected.
    SQL> G.

  • Sql count

    Hi,
    i have a question:
    NAME count
    John 3
    Mark
    Luke
    NAME count
    (null) 0
    if no record return/no data found
    NAME count
    0
    Any idea how to do that SQL ?

    Hi,
    Sorry, I don't understand.
    If you want certain values (including NULL) to appear in the name column even if they do no appear in the table, then you should do an outer join with a tablle that does have them. If you don't have such a table, you can use a sub-query based on dual.
    You can join on NULL, but it's messy. It's easier if you there is some value (like ' ', a single space, or the string '(null)') that you can use to represent NULL jsut for the join. You can display a true NULL, like this:
    WITH  all_names  AS
        SELECT DISTINCT name FROM table_x
        UNION
        SELECT ' ' AS name FROM dual
    SELECT  NULLIF (an.name, ' ')     AS nm
    ,       NVL (COUNT (tx.name), 0)  AS cnt
    FROM             all_names  an
    LEFT OUTER JOIN  table_x    tx  ON an.name = tx.name
    GROUP BY        an.name;If you want something to appear when the query doesn't really produce anything, do a UNION, like this:
    WITH  real_results  AS
        SELECT    name
        ,         COUNT (*)  AS cnt
        FROM      table_x
        GROUP BY  name
    SELECT  *  FROM  real_results
    UNION
    SELECT  NULL AS name
    ,       0 AS cnt
    FROM    dual
    WHERE   NOT EXISTS
            SELECT  1
            FROM    real_results
            );

  • SQL Count Syntax

    I'm building a top 10 leaderboard for contest entries and am
    having some trouble with the sorting on my query. My Query is
    almost working perfectly, however it doesn't seem to be ordering by
    my new variable, 'entries'. Am I missing something somewhere, or is
    my syntax correct? (it doesn't display at all unless I put the
    single quotes on the variable entries).
    <cfquery name="entry_count" datasource="clients">
    select reg_id, count(reg_id) as entries
    from targus_promo_entry
    group by reg_id
    order by 'entries' DESC
    </cfquery>
    Does anyone have any ideas???
    Allison

    Hi Allison,
    Sql syntax varies by database so its good to post which
    database/version you're using.
    Try removing the single quotes around 'entries'
    select reg_id, count(reg_id) as entries
    from targus_promo_entry
    group by reg_id
    order by entries DESC
    But some databases don't allow you to order by an alias, so
    you'd have to use something like
    select reg_id, count(reg_id) as entries
    from targus_promo_entry
    group by reg_id
    order by count(reg_id) DESC

  • SQL count while also concatenating

    Hello,
    I need a query that not only counts but also concatenates a VARCHAR2 field as well.
    I have prior experience doing concatenation using ROW_NUMBER() and SYS_CONNECT_BY_PATH functions found in the below link:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    The problem setup script:
    CREATE TABLE CAR
    CAR_NUM NUMBER PRIMARY KEY,
    CAR_MAKE VARCHAR2(100 BYTE),
    CAR_MODEL VARCHAR2(100 BYTE),
    CAR_YEAR NUMBER,
    CAR_DESC VARCHAR2(4000 BYTE)
    Insert into CAR
    (CAR_NUM, CAR_MAKE, CAR_MODEL, CAR_YEAR, CAR_DESC)
    Values
    (1, 'Toyota', 'Celica', 2002, 'Mid-sized Sports car with 28-32 MPG');
    Insert into CAR
    (CAR_NUM, CAR_MAKE, CAR_MODEL, CAR_YEAR, CAR_DESC)
    Values
    (2, 'Toyota', 'Corolla', 2006, 'Compact economy car');
    Insert into CAR
    (CAR_NUM, CAR_MAKE, CAR_MODEL, CAR_YEAR, CAR_DESC)
    Values
    (3, 'Toyota', 'Corolla', 2007, 'Compact economy car with newly redesigned features');
    The results I need:
    MAKE: MODEL: DESC: COUNT(YEAR):
    Toyota | Corolla | Compact economy car;Compact economy car with newly redesigned features | 2
    Toyota | Celica | Mid-sized Sports car with 28-32 MPG | 1
    I can get the number of years for a specific car make/car model in the below query but can’t figure out how to get the car description to concatenate as well:
    select
    car_make as "Car Make",
    car_model as "Car Model",
    sum(1) as "Years"
    from
    CAR
    group by
    car_make, car_model
    I’m open to all solutions but would prefer SQL. I’m running this on an Oracle 10g database.
    Thanks in advance.

    It could be simplified a little...
    SQL> ed
    Wrote file afiedt.buf
      1  select car_make, car_model
      2        ,max(ltrim(sys_connect_by_path(car_desc,','),',')) as car_desc
      3        ,max(rn) as car_count
      4  from (select car_make, car_model, car_desc
      5              ,row_number() over (partition by car_make, car_model order by car_year) as rn
      6        from car)
      7  connect by car_make = prior car_make and car_model = prior car_model and rn = prior rn + 1
      8* group by car_make, car_model
    SQL> /
    CAR_MAKE
    CAR_MODEL
    CAR_DESC
    CAR_COUNT
    Toyota
    Celica
    Mid-sized Sports car with 28-32 MPG
             1
    Toyota
    Corolla
    Compact economy car,Compact economy car with newly redesigned features
             2
    SQL>

  • Need help on sql count

    SQL> select count(location_ip) from web_stats where page_path='Apple'; (this query is to be solved as I need to count ip addresses of a page path,I getting 0 as result
    COUNT(LOCATION_IP)
    0
    Is there any other query related to above query?

    Null values aren't counted, as mentioned already. Is that what you're asking about? To count rows regardless of whether individual columns have values or not, use <tt> count(*)</tt>.
    I don't know what you mean by "any other queries related to this query".
    btw please use tags for code, e.g.
    {noformat}{noformat}
    select count(*) from mytable;
    {noformat}{noformat}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • PL/SQL: Count how often a value appears and subtotal it

    I'm not the best at PL/SQL, but I'm trying and willing to learn.
    I have some SQL that looks thru over 1 million rows in a DB and pulls back data and does decodes to make the data meaningful. My output looks like this right now
    Row1 - Row2 - Row3 - Row4 - Row5
    x a c d c
    a c d b x
    x c d b b
    x x x a a
    x a b b a
    x = no answer
    a = alpha
    b = beta
    c = charle
    d = delta
    My end goal is to try to do this: Is to try to figure out how many times x appears in a rows above, decode it from 'x' to 'no answer' and then spit out a subtotal. The same applies for A thru D as well.
    Can anyone point out some PL/SQL examples that could help me out?
    thanks

    Two solutions
    create table msw_emp
    (id     varchar2(5),
    row1     varchar2(1),
    row2     varchar2(1),
    row3     varchar2(1),
    row4     varchar2(1),
    row5     varchar2(1))
    insert into msw_emp values('11111', 'x', 'a', 'c', 'd', 'a');
    insert into msw_emp values('22222', 'x', 'a', 'a', 'd', 'd');
    insert into msw_emp values('33333', 'x', 'x', 'x', 'a', 'x');
    insert into msw_emp values('44444', 'a', 'a', 'a', 'a', 'b');
    insert into msw_emp values('55555', 'x', 'x', 'x', 'x', 'x');
    commit;
    Answer Count
    alpha - 9
    beta - 1
    charlie - 1
    delta - 3
    no answer - 11
    #SOLUTION 1
    select 'alhpa' "Answer Count",
    sum(decode(row1, 'a', 1, 0)+
    decode(row2, 'a', 1, 0)+
    decode(row3, 'a', 1, 0)+
    decode(row4, 'a', 1, 0)+
    decode(row5, 'a', 1, 0)) a_count
    from msw_emp
    union all
    select 'beta',
    sum(decode(row1, 'b', 1, 0)+
    decode(row2, 'b', 1, 0)+
    decode(row3, 'b', 1, 0)+
    decode(row4, 'b', 1, 0)+
    decode(row5, 'b', 1, 0)) b_count
    from msw_emp
    union all
    select 'charlie',
    sum(decode(row1, 'c', 1, 0)+
    decode(row2, 'c', 1, 0)+
    decode(row3, 'c', 1, 0)+
    decode(row4, 'c', 1, 0)+
    decode(row5, 'c', 1, 0)) c_count
    from msw_emp
    union all
    select 'delta',
    sum(decode(row1, 'd', 1, 0)+
    decode(row2, 'd', 1, 0)+
    decode(row3, 'd', 1, 0)+
    decode(row4, 'd', 1, 0)+
    decode(row5, 'd', 1, 0)) d_count
    from msw_emp
    union all
    select 'no answer',
    sum(decode(row1, 'x', 1, 0)+
    decode(row2, 'x', 1, 0)+
    decode(row3, 'x', 1, 0)+
    decode(row4, 'x', 1, 0)+
    decode(row5, 'x', 1, 0)) x_count
    from msw_emp
    #SOLUTION 2
    select decode(val,
    'a', 'alpha',
    'b', 'beta',
    'c', 'charlie',
    'd', 'delta',
    'x', 'no answer')||' - '||count(*) "Answer Count"
    from (select row1 val
    from msw_emp
    union all
    select row2
    from msw_emp
    union all
    select row3
    from msw_emp
    union all
    select row4
    from msw_emp
    union all
    select row5
    from msw_emp)
    group by val
    Answer Count
    alpha - 9
    beta - 1
    charlie - 1
    delta - 3
    no answer - 11

  • SQL count(*) return a wrong result

    Hi all, i've got 2 table F_1 and F_2. I also have a view VW based on the previous table that create the join clause.
    If i execute
    select * from
    F_1   F_1,
    VW VW,
    F_2 F2
    where
    F_1.SEQ_LINE = VW.LINEA
    AND
    TO_NUMBER(VW.TESTA) = TO_NUMBER(F_2.SEQ_LINE)
    i obtain 506 rows (the correct result). If i execute
    select count(*) from
    F_1   F_1,
    VW VW,
    F_2 F2
    where
    F_1.SEQ_LINE = VW.LINEA
    AND
    TO_NUMBER(VW.TESTA) = TO_NUMBER(F_2.SEQ_LINE)
    the result is 0. Any idea?
    Thanks, DecaXD

    Hi all, TO_NUMBER was a copy paste error.
    The table (dummy data) is
    CREATE TABLE "F1"
    (     "C1" VARCHAR2(5),
         "SEQ_LINE" NUMBER(8,0)
    -- Records of F1
    INSERT INTO "F1" VALUES ('aaa', '1');
    INSERT INTO "F1" VALUES ('bbb', '4');
    INSERT INTO "F1" VALUES ('ccc', '6');
    CREATE TABLE "D2"
    (     "C1" VARCHAR2(5),
         "SEQ_LINE" NUMBER(8,0)
    -- Records of F2
    INSERT INTO "F2" VALUES ('aaa1', '2');
    INSERT INTO "F2" VALUES ('aaa2', '3');
    INSERT INTO "F2" VALUES ('bbb1', '5');
    INSERT INTO "F2" VALUES ('ccc1', '7');
    The view is
    select F2.SEQ_LINE LINEA ,max(F1.SEQ_LINE) TESTA from F1,F2
    where F2.SEQ_LINE > F1.SEQ_LINE
    group by F2.SEQ_LINE
    ORDER BY 1,2

  • SQL COUNT error

    Hi
    I came across with following difference.
    SELECT COUNT(*) FROM table1 WHERE cardno BETWEEN '10076D' AND '10076D'
    Here I get COUNT = 1
    SELECT COUNT(*) FROM table1 WHERE cardno BETWEEN '10076' AND '10076' ---- [without D]
    Here I get COUNT = 0
    In the application requirement I need to omit 'D' when data entry. But COUNT result should read as 1
    Pl. clarify the data type of cardno is VARCHAR2(20)
    Thax
    shabar

    as i said
    a BETWEEN 1 AND 2 = a >= 1 AND a <= 2
    so, no you cannot use LIKE with BETWEEN
    If you had something like
    WHERE cardno BETWEEN '10076' AND '10080'
    and you want to match this with 10076D, 10077D, 10078D, 10078E, 10080A, ...
    then you would have to do something like
    WHERE SUBSTR(cardno,1,5) BETWEEN '10076' AND '10080'
    but, unless you have a function based index on SUBSTR(cardno,1,5) an index of the cardno column will not be used with this query.
    or you could do
    WHERE cardno BETWEEN '10076' || CHR(0) AND '10080' || CHR(255)
    which is a little bit, lets say crappy
    hth (hope this helps) ;-)

  • Dirty read with READ COMMITTED and sql count.

    Hi,
    Under read committed isolation level a select count(*) ... return 1, in fact the select sees insert during other current transaction, it is typically a dirty read. But a select without count function return 0. Can someone explain me why I have this behaviour ?
    the transaction which is making the select count(*)...has read committed isolation level
    the transaction which has inserted the new item has read uncommitted isolation level
    Please tell me if I am missing something.
    I am using Maxdb 7.6.
    Thx

    Hi there,
    ok, I tried again an was actually able to reproduce the behavior
    The problem here is the special implementation of the count (*) function.
    To get correct results (isolation level wise), you may use count(<primary key>) instead.
    So for your example
    select count (IDDI) from NONO.APPA
    should always deliver the correct result.
    The same is true for the other aggreation functions (min/max/avg...) - it's just about the very special count(*) handling here.
    I informed our development about this.
    thanks for pointing out!
    Lars

Maybe you are looking for

  • Office Home and Student 2013 on Windows 8.1

    I bought the above software for a new laptop from a company called Information Technology Clear Limited. I downloaded it using the key they sent me. To start with it worked on and off, opening some documents, not others, then telling me it couldn't s

  • SELECT .... INTO CORRESPONDING  - Internal table

    How do everyone, I have the following work areas and internal table defintion: TYPES: BEGIN OF equi_rec,            equnr,                  " Registration            herst,                  " Make            typbz,                  " Model           

  • Why do sites in Safari 6's reading list say "waiting"

    I'm running Lion (10.7.4). Ever since I upgraded to Safari 6, the sites listed in Reading List show a "Waiting..." attribute. This never goes away. Any solutions?

  • Connecting to HH3 USB on Mac 10.7.4

    I have attached a formatted fat32 HDD to the USB connector on the Home Hub. It shows up on my network connections under "bthub3" and i can see the "USB_Disk" folder, but everytime I try to enter it keeps showing me a pop up saying "The operation can'

  • Firefox will not open but process runs

    Suddenly I can't get Firefox to open - process runs in task manager but no window comes up at all. Have been using it on this system for a long time with no issues. It isn't the process already running issue which most of us know. Have tried uninstal