SQL Count (*)

-Example query-

with  t as
(select 101,'A' from dual
union all
select 102,'B' from dual
union all
select 103,'C' from dual
union all
select 104,'D' from dual
union all
select 105,'E' from dual)
select * from t;

-----------------------------------

I want to count the total number of lines, but if there are 5 lines in the table that the output will be 4 because the number of users start

0 (0.4) and if his count (*) is 0 then the output should be 0...

I used 'count ()) - 1', but if any rows in the table that was give me - 1 and wrong! I want to 0 instead of-1...

How can I do this please suggest me...

Version of the Oracle :-10 g

Thank you

Xandot

Hello

Xandot wrote:

-Example query-

  1. with t as
  2. (select 101, 'A' from two
  3. Union of all the
  4. Select 102, 'B' double
  5. Union of all the
  6. Select 103, 'C' of the double
  7. Union of all the
  8. Select 104, has ' go two
  9. Union of all the
  10. Select 105, 'E' of the double)
  11. Select * from t;

-----------------------------------

I want to count the total number of lines, but if there are 5 lines in the table that the output will be 4 because the number of users start

0 (0.4) and if his count (*) is 0 then the output should be 0...

I used 'count ()) - 1', but if any rows in the table that was give me - 1 and wrong! I want to 0 instead of-1...

How can I do this please suggest me...

Version of the Oracle :-10 g

Thank you

Xandot

So, you want the output to 0 when there is 0 or 1 rows in the table; Isn't it?

If so:

SELECT THE LARGEST (COUNT ()) - 1

0

), Cnt

T;

Tags: Database

Similar Questions

  • SQL Count query - Assistance needed

    Hello

    Hoping someone can point me in the right direction. Here's the query I have so far. What I'm trying to do is to compare and add the names of the skills of individuals. My current query will count them, however, I need to take a step further where if the person has a name of "Spanish" skills can only which is counted and not their names other skills.

    Current query:

    WITH AS TBL1

    (SELECT

    TRIM (A.NWIE_ID) AS NWIE_ID,

    A.AGENT_NM,

    B.BUSINESS

    Of

    LIGHTHOUSE. IEX_AGENTS A JOIN

    LIGHTHOUSE. TBL_GEN_MU_BUSINESS B

    ON A.MU_ID = B.MU_ID

    WHERE B.BUSINESS IN ('PL_LEGACY'));

    TBL2 ACE

    (SELECT

    TRIM (C.USER_ID) AS USER_ID,

    TRUNC (ASOF_DT, 'IW') AS WEEKBEGINNING,

    CASE

    WHERE (SKILL_NM = 'PLSCLegacy' AND SKILL_LEVEL < = 2) THEN "basic".

    WHERE (SKILL_NM = 'PLSCLegacy' AND SKILL_LEVEL < = 7) THEN "moderate."

    WHERE (SKILL_NM = 'PLSCLegacy' AND SKILL_LEVEL < = 10) THEN 'complex '.

    WHERE (SKILL_NM = "PLSCLegacySpanish") THEN 'Spanish '.

    Another null

    END AS SKILL_NM

    THE LIGHTHOUSE. C CFG_PERSON_SKILL_HIST

    )

    SELECT

    WEEKBEGINNING,

    SKILL_NM,

    COUNT (DISTINCT NWIE_ID) TOTAL_SKILLED

    Of

    TBL1,

    TBL2

    WHERE TBL1. NWIE_ID = TBL2. USER_ID

    AND SKILL_NM NOT IN ('NULL %')

    SKILL_NM GROUP, WEEKBEGINNING

    ORDER OF WEEKBEGINNING, SKILL_NM

    Create the Table data:

    CREATE TABLE IEX_AGENTS

    (

    AGENT_NM VARCHAR2 (20).

    NWIE_ID CHAR (8),

    NUMBER OF MU_ID (5)

    )

    CREATE TABLE TBL_GEN_MU_BUSINESS

    (

    BUSINESS VARCHAR2 (100),

    NUMBER OF MU_ID (5)

    )

    CREATE TABLE CFG_PERSON_SKILL_HIST

    (

    USER_ID VARCHAR2 (8).

    DATE OF ASOF_DT,

    SKILL_NM VARCHAR2 (64).

    NUMBER OF SKILL_LEVEL (10)

    )

    INSERT INTO IEX_AGENTS (AGENT_NM, NWIE_ID, MU_ID) VALUES ("Marcelle, Athalie", "MARCELA1", 5)

    INSERT INTO IEX_AGENTS (AGENT_NM, NWIE_ID, MU_ID) VALUES ('Lister, Laura", 'LISTERL3', 6)

    INSERT INTO IEX_AGENTS (AGENT_NM, NWIE_ID, MU_ID) VALUES ("Purvis, Bradley", 'PURVIB1', 4)

    INSERT INTO IEX_AGENTS (AGENT_NM, NWIE_ID, MU_ID) VALUES ("Cannon, Mark", "CANNON1", 4)

    INSERT INTO TBL_GEN_MU_BUSINESS (BUSINESS, MU_ID) VALUES ('PL_LEGACY', 5)

    INSERT INTO TBL_GEN_MU_BUSINESS (BUSINESS, MU_ID) VALUES ('PL_LEGACY', 6)

    INSERT INTO TBL_GEN_MU_BUSINESS (BUSINESS, MU_ID) VALUES ('PL_LEGACY', 4)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('PURVIB1', 3/9/2014 12:00 ',' PLSCLegacy', 1).

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('MARCELIA1', 3/9/2014 12:00 ',' PLSCLegacy', 10)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('LISTERL3', 3/9/2014 12:00 ',' PLSCLegacy', 7)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('CANNON1', 3/9/2014 12:00 ',' PLSCLegacy', 7)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('MARCELIA1', 3/9/2014 12:00 ',' PLSCLegacySpanish', 3)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('LISTERL3', 3/9/2014 12:00 ',' PLSCLegacySpanish', 6)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('PURVIB1', 3/9/2014 12:00 ',' PLSCLegacySpanish', 2)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('PURVIB1', 3/19/2014 12:00 ',' PLSCLegacy', 10)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('LISTERL3', 3/19/2014 12:00 ',' PLSCLegacy', 2)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('MARCELIA1', 3/9/2014 12:00 ',' PLSCLegacy', 10)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('CANNON1', 3/19/2014 12:00 ',' PLSCLegacy', 7)

    INSERT INTO CFG_PERSON_SKILL_HIST (USER_ID, ASOF_DT, SKILL_NM, SKILL_LEVEL) VALUES ('CANNON1', 3/19/2014 12:00 ',' PLSCLegacySpanish', 7)

    Results of the current query:

    WEEKBEGINNINGSKILL_NMTOTAL_SKILLED
    07/03/2014 12:00:00 AMFoundational1
    07/03/2014 12:00:00 AMComplex1
    07/03/2014 12:00:00 AMModerate2
    07/03/2014 12:00:00 AMSpanish3
    14/03/2014 12:00:00 AMFoundational1
    14/03/2014 12:00:00 AMComplex2
    14/03/2014 12:00:00 AMModerate1
    14/03/2014 12:00:00 AMSpanish1

    Desired results:

    WEEKBEGINNINGSKILL_NMTOTAL_SKILLED
    07/03/2014 12:00:00 AMFoundational0
    07/03/2014 12:00:00 AMComplex0
    07/03/2014 12:00:00 AMModerate1
    07/03/2014 12:00:00 AMSpanish3
    14/03/2014 12:00:00 AMFoundational1
    14/03/2014 12:00:00 AMComplex2
    14/03/2014 12:00:00 AMModerate0
    14/03/2014 12:00:00 AMSpanish1

    WITH ACE TBL1)

    SELECT TRIM (A.NWIE_ID) AS NWIE_ID,

    A.AGENT_NM,

    B.BUSINESS

    OF IEX_AGENTS HAS

    JOIN THE

    TBL_GEN_MU_BUSINESS B

    ON A.MU_ID = B.MU_ID

    WHERE B.BUSINESS IN ("PL_LEGACY")

    ),

    (ACE TBL2)

    SELECT USER_ID, TRIM (C.USER_ID)

    TRUNC (ASOF_DT, 'IW') AS WEEKBEGINNING,

    CASE

    WHERE (SKILL_NM = 'PLSCLegacy' AND SKILL_LEVEL<= 2)="" then="">

    WHERE (SKILL_NM = 'PLSCLegacy' AND SKILL_LEVEL<= 7)="" then ="">

    WHERE (SKILL_NM = 'PLSCLegacy' AND SKILL_LEVEL<= 10)="" then ="">

    WHERE (SKILL_NM = "PLSCLegacySpanish") THEN 'Spanish '.

    END AS SKILL_NM

    OF CFG_PERSON_SKILL_HIST C

    ),

    (AS TBL3)

    SELECT USER_ID,

    WEEKBEGINNING,

    SKILL_NM,

    COUNT)

    SKILL_NM SEPARATE CASE

    WHEN 'Spanish', 1

    END

    ) HAS_SPANISH OVER (PARTITION BY USER_ID, WEEKBEGINNING)

    FOR TBL2

    )

    SELECT WEEKBEGINNING,

    SKILL_NM,

    COUNT)

    SEPARATE CASE

    WHEN HAS_SPANISH = 0 THEN NWIE_ID

    WHEN SKILL_NM = "Spanish" THEN NWIE_ID

    END

    ) TOTAL_SKILLED

    FROM TBL1;

    TBL3

    WHERE TBL1. NWIE_ID = TBL3. USER_ID

    AND SKILL_NM NOT IN ('NULL %')

    SKILL_NM GROUP,

    WEEKBEGINNING

    ORDER OF WEEKBEGINNING,

    SKILL_NM

    /

    WEEKBEGINNING SKILL_NM TOTAL_SKILLED
    ---------------------- ------------ -------------
    03/03/2014 12:00:00 am founders 0
    03/03/2014 moderate from 12:00:00 am 0
    03/03/2014 12:00:00 am 2 Spanish
    17/03/2014 12:00:00 am complex 1
    17/03/2014 12:00:00 am basic 1
    17/03/2014 12:00:00 am Spanish 1

    6 selected lines.

    SQL >

    SY.

  • GROUP OF + SQL COUNT + SUM

    Hello

    I have a table, it has 2 colunms, (name, number)

    name number
    B1 7
    B1 7
    B1 28
    B1 28
    B1 28
    B2 7
    B2 28
    B3 7
    . .
    . .
    .
    .


    I want to see below

    number
    name sum 7sum 28sum

    5 2 3 B1
    2 1 1 B2
    B3...
    .
    .
    .
    .
    .


    Can you help me

    THANK YOU VERY MUCH FOR HELP

    Like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 'B1' as name, 7 as num from dual union all
      2             select 'B1', 7 from dual union all
      3             select 'B1', 28 from dual union all
      4             select 'B1', 28 from dual union all
      5             select 'B1', 28 from dual union all
      6             select 'B2', 7 from dual union all
      7             select 'B2', 28 from dual union all
      8             select 'B3', 7 from dual)
      9  --
     10  -- end of test data - use query below
     11  --
     12  select name
     13        ,count(*)
     14        ,sum(decode(num,7,1,0)) as sum7
     15        ,sum(decode(num,28,1,0)) as sum28
     16  from t
     17  group by name
     18* order by 1
    SQL> /
    
    NA   COUNT(*)       SUM7      SUM28
    -- ---------- ---------- ----------
    B1          5          2          3
    B2          2          1          1
    B3          1          1          0
    
  • SQL Count helps

    Hello world

    I need to display the SPER_STATUS_TEXT count as 0 if there is no data from query below. Could someone help me please

    SQL > SELECT a.sper_status_text, COUNT (*)
    2 from (SELECT sper.assettxt,
    CASE 3
    4. WHEN sper.sper_status_text = "assessment" said.
    5 THEN
    6 'confirmed assessment '.
    7. WHEN sper.sper_status_text AS "update - rated %".
    8 THEN
    9 "update - rated up to."
    10. WHEN sper.sper_status_text AS "update - % evaluated.
    11. CAN
    12 'update - rated down"
    13 ELSE
    14 "other responses.
    15 END
    16 sper_status_text
    17 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 <>'! MAD
    (22) a
    23 GROUP BY a.sper_status_text
    ORDER 24 (CASE
    25. WHEN a.sper_status_text = "Said assessment" THEN 1
    26. WHEN a.sper_status_text = "update - evaluated until ' THEN 2
    27. WHEN a.sper_status_text = 'Update - rated down' THEN 3
    28 4 SOMETHING ELSE
    END 29);

    Results:
    SPER_STATUS_TEXT COUNT (*)
    ------------------------ ----------
    Claims assessment 2

    I need to display as below (if there no data I need to display the number as 0)
    SPER_STATUS_TEXT COUNT (*)
    ------------------------ ----------
    Claims assessment 2
    Updated - evaluated up to 0
    Updated - rated low 0
    Other answers 0

    Please advice

    You can get this. Using the TYPE 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 (*) with Group of

    Hello

    I need help to fix this SQL.

    Fields in the table are like that.
    ID(PK)
    user_id
    user_name
    login_time(timestamp)
    Basically I want the values of user_id, user_name, last time the logged-in user and total number of times the user
    select  distinct user_id , user_name, login_date from USER_LOGIN
    where login_date in (select max(login_date) from USER_LOGIN group by user_id) 
    the above query is to give the result set with user_id, user_name, last time that the user logged on, but how can I include count (*) Group of user_id in the sql above
    select  distinct user_id , user_name, login_date, count(*) from USER_LOGIN
    where login_date in (select max(login_date) from USER_LOGIN group by user_id)  group by user_id 
    the sql above does not work.

    can you help me to get the number of records by user_id group.

    Thank you
    SK

    Hello

    Looks like you want something like this:

    SELECT       user_id
    ,       user_name
    ,       MAX (login_time)     AS last_login_time
    ,       COUNT (*)          AS total_rows
    FROM       user_login
    GROUP BY  user_id
    ,            user_name
    ;
    

    This assumes that user_login is off standard (like him are often seen), such that every row of the same user_id will also have the same user_name.

    I hope that this answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.

  • SQL Count - is it possible?

    To be used at the APEX, I am trying to accomplish the following:

    Have a read to the user indicating how much of a certain task is available:

    IE:
    There is 'X' associated tasks 'name of the project.

    However, I get an error whenever an attempt to save the code, the code is as follows:
    select 
        'There are ' ||count(distinct pd.fk_tasks_id) ||' tasks for project ' ||pm.name
    
    from
        protrac_master pm,
        protrac_detail pd
    
    where
        pk_proj_master_id = pk_proj_detail_id
    I tried both the single and double quotes.

    Hello

    Leland says:
    ... Wouldn't put an alias defeat the whole point of what I was trying to do?

    Lol why do you think that it would frustrate the object?

    select
        'There are ' ||count(distinct pd.fk_tasks_id) ||' tasks for project ' ||pm.name
            AS  txt
    from protrac_master pm, protrac_detail pd
    where pk_proj_master_id = pk_proj_detail_id
    GROUP BY pm.name
    

    In addition, the statement runs a toad.

    He would probably run in SQL * more, too, but not in all contexts where you would have to refer to columns.

  • Need of a just rows in table using SQL counter bearing

    Oracle 11 g 2

    RHEL 6.4

    ---------------

    Given the following table data:

    EMPLOYEE HIRE_DATE TERM_DATE DEPT

    ------------------     -----------------     ------------------      ---------

    John Doe 01/01/13 101

    Jane Smith 05/01/13 102

    Bob Jones 102 02/04/13, 22/04/13

    Jenny Boo 03/12/13 03/31/13 103

    Joe Schmoe 24/03/13 102

    Bill Max 23/04/13 103

    Jill clay 24/04/13 103

    Joe Boom 11/05/13 102

    I want to return the number of employees who work for each month, as long as they were hired at anytime during the month and what if they ended this month (ie the month worries me).  So I would expect

    EMPLOYEE OF THE MONTH

    Jan 2

    3 Feb

    5 March

    April 6 (Jenny Boo ended)

    May 6 (Jenny Boo and Bob Jones have been completed)

    I know there are bright people out there who are SQL expert, but I'm not one of them.  If there is a way to do this in SQL just I would like to see it.

    Hello stew,.

    Thanks for your reply.  Looking at your SQL, where did you get the column "cnt"?  I don't see that in any table, physical or virtual.

    It is in the clause "unpivot" of the request he posted.

    Create the table "emp1" and the data that Martin condition and then run the query that provided stew.

    Works for me:

    Select to_char (Lun, ' FMMonth, YYYY') month,

    Sum (Sum (TO_NUMBER (CNT))) more employees (command per LUN)

    de)

    Select trunc (hire_date, 'MM') "1."

    trunc (ADD_MONTHS(term_date,1), 'MM') '-1 '.

    from emp1

    ) a

    UNPIVOT (LUN for NTC in ("1", "-1"))

    LUN group

    order by Lun;

    Header 1 Header 2

    MONTH

    EMPLOYEES January 2013 2 February 2013 3 March 2013 5 April 2013 6 May 2013 6

  • Using SQL, count of values

    I have 3 fields in a Table that I need to run a report, they are phone fields, as:

    pl_home
    pl_cell
    pl_other

    some clients have no phone number in any of these areas, some might have 1, 2, every 3.

    What is the best way to count these phone numbers by using more than one field?

    the fields will be either null (for no number) or have a number...

    What is the best way? Examples would be appreciated.

    Thank you.

    What counts? How many phones each client has? Then use:

    nv2l(pl_home,1,0) + nvl2(pl_cell,1,0) + nvl2 (pl_other, 1, 0)

    SY.

  • query SQL - COUNT (1)

    Hi all
    Under request, could someone explain COUNT (1) means?
    INSERT INTO edr_class_by_speed_report_data
      (
        site_id,
        site_lane_id,
        interval_start_date_time,
        vehicle_class,
        vehicle_speed,
        vehicle_count
      )
      SELECT site_id,
             site_lane_id,
             interval_start_date_time,
             vehicle_class,
             speed,
             COUNT(1)
      FROM (
             SELECT site_id,
                    site_lane_id,
                    (SELECT MAX(interval_start_date_time)
                     FROM edr_rpt_tmp_grouping_table
                     WHERE interval_start_date_time <= date_time) interval_start_date_time,
                    vehicle_class,
                    NVL( (SELECT MAX (min_speed)
                                FROM edr_rpt_tmp_speed_ranges
                                WHERE min_speed <= ROUND(vehicle_speed)
                               ),
                               0 )  speed
            FROM    edr_class_by_speed_veh_data
            WHERE edr_class_by_speed_veh_data.vehicle_error_count  = 0
           )
        GROUP BY site_id,
                 site_lane_id,
                 interval_start_date_time,
                 vehicle_class,
                 speed;
    Thanks in advance.

    It stands for count (*). See this AskTom discussion thread: [select Count (1) how it works | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1156151916789]

  • SQL COUNT error

    Hello

    I found with the following differences.



    SELECT COUNT (*) FROM table1 WHERE cardno BETWEEN ' 10076 of AND 10076 of

    Here I get COUNT = 1



    SELECT COUNT (*) FROM table1 WHERE cardno BETWEEN '10076' AND '10076'-[without]


    Here I get COUNT = 0




    In the request, requirement, I need to omit had ' during data entry. But the result COUNT should be read as 1
    PL. clarify the data type of Caron is VARCHAR2 (20)

    Thax

    sexy

    as I said

    BETWEEN 1 AND 2 = a > = 1 AND a<=>

    so, no, you can't use LIKE with BETWEEN

    If you had something like

    WHERE Caron BETWEEN '10076' AND '10080'

    and you want to match it with 10076D, D 10077, 10078D, 10078E, 10080A...

    Next, you will need to do something like

    WHERE SUBSTR (cardno, 1, 5) BETWEEN '10076' AND '10080'

    but, unless you have a clue of the function based on SUBSTR(cardno,1,5) it be not used to an index of the Caron column with this request.

    or you could do

    WHERE Caron BETWEEN '10076' | CHR (0) AND '10080' | CHR (255)

    which is a bit, say shit

    HTH (hope this helps) ;-)

  • view the data in SQL

    I was able to use ASP to retrieve data from SQL database by using something like the one below:

    SQL = "SELECT PageName",

    SQL = SQL & "CONVERT (NUMERIC (6,2), AVG(Rating * 1.00))" AVERAGE ".

    SQL = SQL & 'COUNT (Rating) AS Total',

    SQL = SQL & "SUM(CASE WHEN Rating = 1 THEN 1 ELSE 0 END) AS [Star1Total]"

    SQL = SQL & "SUM(CASE WHEN Rating = 2 THEN 1 ELSE 0 END) AS [Star2Total]"

    SQL = SQL & "SUM(CASE WHEN Rating = 3 THEN 1 ELSE 0 END) AS [Star3Total]"

    SQL = SQL & "SUM(CASE WHEN Rating = 4 THEN 1 ELSE 0 END) AS [Star4Total]"

    SQL = SQL & "SUM(CASE WHEN Rating = 5 THEN 1 ELSE 0 END) AS [Star5Total].

    SQL = SQL & "FROM [SDBI]. [dbo]. [GnieRatePage] "

    SQL = SQL & "GROUP BY PageName".

    SQL = SQL & "ORDER BY PageName".

    I then post on the help page:

    Response.Write ("PageName") Recordset

    What I need, it of to transmit these data to Flash and let Flash to view the coast. How to do by way of ASP?

    Thank you

    I don't use the proper syntax for writing couples variable/value with asp, but, if this is the case, use:

    var myTextLoader:URLLoader = new URLLoader();

    myTextLoader.dataFormat = pouvez;

    myTextLoader.addEventListener (Event.COMPLETE, onLoaded);

    function onLoaded(e:Event):void

    {

    for {(var s:String in e.target.data)

    trace (s, e.Target.Data [s]);

    }

    myTextLoader.load (new URLRequest ("read_page_rating.asp"));

  • Rows affected the dynamic SQL


    Hello

    VERSION - Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64 bit Production

    I want the number of rows affected by SQL dynamic, as shown below in the code where insert statement will be repeated for each record in the CURSOR.

    for rec in c1
    loop


    ABC: =' insert into test
    Select a.*,' | recomm. OP_ID |', "' | recomm. OP_NAME | " 'of BL_testI' | recomm. OP_ID: ' where START_DATE > = trunc(sysdate-2) and START_DATE < trunc(sysdate-1)';

    insert into str_test values (abc);

    immediately run abc;

    commit;

    When exit c1% notfound;
    end loop;

    In a normal query I would do it spontaneously SQL COUNT but cannot use it here.

    Thnx in advance

    Just use SQL % ROWCOUNT. What is the problem with that?

    Here is an example.

    SQL > declare
    l_sql 2 varchar2 (4000);
    3. start
    4 l_sql: = ' insert into t select * from emp';
    5. immediately run l_sql;
    6 dbms_output.put_line(l_sql ||) ': Number of inserted rows = ' | to_char(SQL%RowCount));)
    7 end;
    8.

    insert into t select * from EMP: number of inserted rows = 11

    PL/SQL procedure successfully completed.

    SQL >

  • Extract data using SQL Expression

    Hello, I created an intermediate table and just realized that I need some new additional fields.
    Should I create them in the scene or in the target table?

    I want to use the SQL COUNT expression to fill these new data sources published, fields
    but do not know exactly how do. I'm a little amateur.

    Thank you.

    You should check the analytical functions:

    http://www.orafaq.com/node/55

  • Query for object counts

    Oracle 11.2.0.1

    I have to generate a count of all types of objects below style.
    USERNAME     TABLES          INDEXES          MVS          PROCEDURES     FUNCTIONS     CLUSTER     
    USER1              10                   5            1                  20             5
    USER2                                2
    USER3                                                                 10
    
    TOTAL               10                5           3                     20               5           10
    Here the object count should correspond with the sum of the column total i.e. 10 + 5 + 3 + 20 + 5 + 10.

    Kindly help me, how to generate above exit.

    Thank you.
    SET        FEEDBACK        OFF
    SET        PAGESIZE        0
    spool c:\dynamic_pivot_subscript.sql
    SELECT     DISTINCT
       ',      COUNT (CASE WHEN object_type = '''
    || object_type
    || ''' '   AS txt1
    ,  'THEN 1 END)    AS "'
    || object_type
    || '_CNT"'  AS txt2
    FROM all_objects
    ORDER BY   txt1;
    SPOOL OFF;
    
    I opened c:\dynamic_pivot_subscript.sql and removed first and last lines.
    
    break on report
    select 'compute sum of "' || object_type || '_CNT" on report'
    from all_objects
    group by object_type
    /
    
    I just executed above lines which I got as query output.
    
    SET LINE 1000;
    compute sum of "TOTAL" on report
    COLUMN OWNER FOR A20;
    SET        FEEDBACK        ON
    SET        PAGESIZE        50
    spool c:\dynamic_pivot.lst
    SELECT OWNER
    @@c:\dynamic_pivot_subscript.sql
    ,COUNT(*) "TOTAL"
    FROM ALL_OBJECTS
    GROUP BY OWNER
    ORDER BY OWNER
    /
    

    Crusader dynamic source: Frank @ Re: County report and the sum of the number of lines in the number of columns

    Concerning
    Girish Sharma

  • Number of SQL Version in AWR and child cursor

    Hello
    In 11.1.0.7, which is Version SQL count in AWR report? What it means? and how oracle performs this version? How do we define child cursor?

    Thank you

    Hello

    Take a look at http://viveklsharma.wordpress.com/2009/09/12/ql/

    Concerning
    Anand

Maybe you are looking for

  • How to recover my email my email of Softmaker Client form?

    I just installed Thunder that works very well, how to recover my contacts and saved emails from Softmaker 2012 E customer?

  • World of Warcraft on Tecra M5 with Nvidia video problem

    Hello I own a laptop very well supported - Toshiba Tecra M5 with the following specifications Processor: Intel Centrino Duo - T2600 @ 2.16 GHz and 2.16 GHzRAM: 4 GBVideo: Nvidia Quadro NVS 110MOS: Windows Vista Ultimate 32-bit (on the highest perform

  • Blackmailed

    I need help! I am currently getting blackmailed for a "cam session" where appeared the inappropriate body parts and requires I pay 'her' or the clip that we have sent to all my friends on Facebook. I should have gotten a check of the age, but I thoug

  • dosent work audio facetime on mac

    Hey then, all of a sudden when I try to make conversation on audio facetime with my mac, I do not hear enything and the other party can't hear me. my mac and iphone are connercted to the wyfii and the facetime video works perfectly... its my phone is

  • HP G5470UK - upgrade the power supply

    I want to install a more powerful graphics card but told me that before I do so I need to upgrade the PSU in my G5470uk of the machine.  Currently of 300w, what would be the recommended size of a power supply for this particular stock pc - there is n