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

Similar Messages

  • ANSI SQL 92 SYNTAX OUTER JOIN PERFORMANCE ISSUE

    Good Morning
    Could anyone explain why the excution time for these two (ment to be identical)
    queries run so differently.
    oracle syntax execution time 1.06 seconds
    select COUNT(*) from
    PL_EVENT_VIEW pev,
    PL_EVENT_STAFF_VIEW pesv
    WHERE pev.EVENT_ID=PESV.EVENT_ID(+)
    AND pev.WEEKS=PESV.WEEK_NUM(+)
    AND pev.event_id=2520
    ansi sql 92 syntax execution time 7.05 seconds
    select COUNT(*) from
    PL_EVENT_VIEW pev
    LEFT JOIN PL_EVENT_STAFF_VIEW pesv
    ON (pev.EVENT_ID=PESV.EVENT_ID
    AND pev.WEEKS=PESV.WEEK_NUM)
    WHERE pev.event_id=2520
    Thanks
    David Hills

    BTW Oracle outer join operator (+) and ANSI SQL OUTER JOIN syntax are NOT equivalent. Consider following:
    DROP TABLE T1;
    CREATE TABLE T1 (C1 NUMBER);
    DROP TABLE T2;
    CREATE TABLE T2 (C2 NUMBER);
    DROP TABLE T3;
    CREATE TABLE T3 (C3 NUMBER);
    -- Following SELECT works:
    SELECT COUNT(*)
         FROM T1, T2, T3
         WHERE C2 = C1
              AND C3(+) = C1
    COUNT(*)
    0
    -- But:
    SELECT COUNT(*)
         FROM T1, T2, T3
         WHERE C2 = C1
              AND C3(+) = C1
              AND C3(+) = C2
    AND C3(+) = C1
    ERROR at line 4:
    ORA-01417: a table may be outer joined to at most one other table
    -- However with ANSI syntax:
    SELECT COUNT(*)
         FROM T1
         JOIN T2 ON (C2 = C1)
         LEFT JOIN T3 ON (C3 = C1 AND C3 = C2)
    COUNT(*)
    0

  • 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);

  • Help with translating SQL query from SQL Server syntax to Oracle syntax

    Hi,
    is it someone that can help me translate following SQL query from SQL Server syntax to Oracle syntax.
    SELECT ID,
    [LMT(MTR)] = MAX(case when TYPE = 'LMT' then VALUE end),
    [AAD(KGM)] = MAX(case when TYPE = 'AAD' then VALUE end),
    [VOL(MTQ)] = MAX(case when TYPE = 'VOL' then VALUE end)
    FROM yourtable
    GROUP BY ID
    Your help is highly appreciated, thanks in advance.

    Like this,
    SELECT ID,
    MAX(case when TYPE = 'LMT' then VALUE end) LMT_MTR,
    MAX(case when TYPE = 'AAD' then VALUE end) AAD_KGM ,
    MAX(case when TYPE = 'VOL' then VALUE end) VOL_MTQ
    FROM yourtable
    GROUP BY ID-Arun

  • Sql-92 syntax in Oracle Lite 8i

    The Oracle Lite documentation instructs the developer to enact this change to polite.ini to use sql-92 syntax:
    Running SQL-92 on Oracle Lite
    As mentioned in the preceding section,
    Oracle Lite uses Oracle SQL by default.
    However, if you want to support SQL-92 by
    default instead of Oracle SQL, you can
    change the SQL compatibility parameter in
    the POLITE.INI file to SQL-92. To change
    the parameter, add the following in the
    POLITE.INI file:
    SQLCOMPATIBILITY=SQL92
    See the Oracle Lite User's Guide for more
    information about the POLITE.INI file.
    However this does not appear to have any effect. For instance, this query in the polite sample database:
    select product.descrip,price.stdprice
    from product FULL OUTER JOIN price
    ON product.prodid = price.prodid;
    generates a syntax error:
    ERROR at line 1:
    OCA-30021: error preparing/executing SQL
    statement
    [POL-5228] syntax error
    Is there more steps needed to make Oracle 8i Lite SQL-92 Compatible???

    Hello,
    SELECT 'x'
    FROM EMP,DEPT
    WHERE
      EMP.dept_id = DEPT.dept_id
    AND
      ROWNUM = 1;Francois

  • Update to ansi 99 sql join syntax

    Hello All
    I'm updating some code to ansi 99 compliant sql.
    I have
    SELECT
      CL_ASSIGNED_NUMBERS2.TITLE,
      CL_ASSIGNED_NUMBERS2.FIRST_NAME,
      CL_ASSIGNED_NUMBERS2.SURNAME,
      CL_ASSIGNED_NUMBERS2.NUM,
      CL_NUMBERS2.OTHER_NUM,
      CL_ASSIGNED_NUMBERS2.LOCATION,
      CL_AS_DEPTS.DEPT_NAME,
      CL_FURTHER_CONTACTS.TITLE,
      CL_FURTHER_CONTACTS.FIRST_NAME,
      CL_FURTHER_CONTACTS.SURNAME,
      EMAIL.LSE_EMAIL,
      CL_ASSIGNED_NUMBERS2.NUMBER_DESC,
      CL_FURTHER_CONTACTS.NUM,
      CL_FURTHER_CONTACTS.LOCATION,
      CL_ASSIGNED_NUMBERS2.AREA,
      CL_ASSIGNED_NUMBERS2.DESC_DIR_ENTRY,
      CL_ASSIGNED_NUMBERS2.AREA_DIR_ENTRY,
      CL_NUMBERS3.OTHER_NUM,
      CL_ASSIGNED_NUMBERS2.PREF_EMAIL
    FROM
      CALL_LOG.CL_ASSIGNED_NUMBERS  CL_ASSIGNED_NUMBERS2,
      CALL_LOG.CL_NUMBERS  CL_NUMBERS2,
      CALL_LOG.CL_DEPARTMENTS  CL_AS_DEPTS,
      CALL_LOG.CL_ASSIGNED_NUMBERS  CL_FURTHER_CONTACTS,
      CALL_LOG.CURRENT_PERSONAL_EMAILS  EMAIL,
      CALL_LOG.CL_NUMBERS  CL_NUMBERS3
    WHERE
      ( CL_ASSIGNED_NUMBERS2.FURTHER_CONTACT_CAN_ID=CL_FURTHER_CONTACTS.CAN_ID(+)  )
      AND  ( CL_ASSIGNED_NUMBERS2.DEPT_CODE=CL_AS_DEPTS.DEPT_CODE(+)  )
      AND  ( CL_NUMBERS2.NUM=CL_ASSIGNED_NUMBERS2.NUM(+)  )
      AND  ( CL_ASSIGNED_NUMBERS2.PLAY_REF=EMAIL.PLAY_REF(+)  )
      AND  ( CL_FURTHER_CONTACTS.NUM=CL_NUMBERS3.NUM(+)  )which i have rewritten as
    SELECT
      AS_NO.TITLE,
      AS_NO.FIRST_NAME,
      AS_NO.SURNAME,
      AS_NO.NUM,
      NO.OTHER_NUM,
      AS_NO.LOCATION,
      DEPT.DEPT_NAME,
      AS_NO.TITLE,
      CONS.FIRST_NAME,
      CONS.SURNAME,
      EMAIL.LSE_EMAIL,
      AS_NO.NUMBER_DESC,
      CONS.NUM,
      CONS.LOCATION,
      AS_NO.AREA,
      AS_NO.DESC_DIR_ENTRY,
      AS_NO.AREA_DIR_ENTRY,
      NOS.OTHER_NUM,
      AS_NO.PREF_EMAIL
    FROM CL_ASSIGNED_NUMBERS AS_NO
    LEFT OUTER JOIN CL_ASSIGNED_NUMBERS CONS ON (AS_NO.FURTHER_CONTACT_CAN_ID=CONS.FURTHER_CONTACT_CAN_ID)
    LEFT OUTER JOIN CL_DEPARTMENTS DEPT ON (AS_NO.DEPT_CODE=DEPT.DEPT_CODE)
    LEFT OUTER JOIN CL_NUMBERS NO ON (AS_NO.NUM=NO.NUM)
    LEFT OUTER JOIN CURRENT_PERSONAL_EMAILS EMAIL ON (AS_NO.PLAY_REF=EMAIL.PLAY_REF)
    LEFT OUTER JOIN CL_NUMBERS NOS ON (CONS.NUM=NOS.NUM)with the first query i get 8130 rows, with the second I get 9676.
    Yet to me the seem like the same query. Can anyone give me an idea as to where I've gone wrong?
    Thanks and Regards
    Ali

    select count (*)
    FROM
    CALL_LOG.CL_ASSIGNED_NUMBERS  CL_ASSIGNED_NUMBERS2,
    CALL_LOG.CL_NUMBERS  CL_NUMBERS2,
    CALL_LOG.CL_ASSIGNED_NUMBERS  CL_FURTHER_CONTACTS
    WHERE
    ( CL_ASSIGNED_NUMBERS2.FURTHER_CONTACT_CAN_ID=CL_FURTHER_CONTACTS.CAN_ID(+)  )
    AND ( CL_NUMBERS2.NUM=CL_ASSIGNED_NUMBERS2.NUM(+) )
      COUNT(*)
          8130
    select count (*) from
    CL_NUMBERS NO
    LEFT OUTER JOIN CL_ASSIGNED_NUMBERS AS_NO ON (AS_NO.NUM = NO.NUM)
      4  LEFT OUTER JOIN CL_ASSIGNED_NUMBERS CONS ON (AS_NO.FURTHER_CONTACT_CAN_ID = CONS.FURTHER_CONTACT_CAN_ID)
      5  .
    SQL> /
      COUNT(*)
         10268Can this be reduced to two tables (aliases) only? Or, which single table/alias produces the discrepancy?
    Can either or both of NUM and FURTHER_CONTACT_CAN_ID in CL_NUMBERS be NULL, or FURTHER_CONTACT_CAN_ID in CL_ASSIGNED_NUMBERS be NULL?
    If any of those columns on the LEFT side the OUTER JOIN can be NULL, can you wrap it/them with NVL(,0), and try both counts again, i.e.,
    select count (*)
    FROM
    CALL_LOG.CL_ASSIGNED_NUMBERS  CL_ASSIGNED_NUMBERS2,
    CALL_LOG.CL_NUMBERS  CL_NUMBERS2,
    CALL_LOG.CL_ASSIGNED_NUMBERS  CL_FURTHER_CONTACTS
    WHERE
    ( NVL(CL_ASSIGNED_NUMBERS2.FURTHER_CONTACT_CAN_ID,-9)=CL_FURTHER_CONTACTS.CAN_ID(+))
    AND (NVL(CL_NUMBERS2.NUM,-9)=CL_ASSIGNED_NUMBERS2.NUM(+) )
    select count (*) from
    CL_NUMBERS NO
    LEFT OUTER JOIN CL_ASSIGNED_NUMBERS AS_NO ON (NVL(AS_NO.NUM,-9) = NO.NUM)
    LEFT OUTER JOIN CL_ASSIGNED_NUMBERS CONS ON (NVL(AS_NO.FURTHER_CONTACT_CAN_ID,-9) = CONS.FURTHER_CONTACT_CAN_ID)Assuming that both those columns are numeric, and that '-9' is not a valid value for those columns.
    Edited by: SeanMacGC on Apr 8, 2009 12:34 PM

  • 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.

  • MDX TOP 10 COUNT SYNTAX ERROR

    Good Morning all,
    When i'm using the following MDX i'm getting the below error
    TITLE: Microsoft Visual Studio
    MdxScript(SR and WO Cube) (63, 5) Parser: The syntax for 'SELECT' is incorrect.
    BUTTONS:
    OK
    SELECT
    [Measures].[SR Count] ON COLUMNS,
    NON EMPTY
    GENERATE (
    [SR Problem].[PROBCODE].MEMBERS,
    [SR Problem].[PROBCODE].CURRENTMEMBER
    TOPCOUNT(
    [SR Problem].[PROBCODE].MEMBERS,
    10,
    [Measures].[SR Count]
    ON ROWS
    FROM [SR and WO Cube]
    Can anyone please point out what i'm missing here?

    Thanks am using the exact sql and getting the same error message
    SELECT
    {[Measures].[SRCOUNT]} ON
    COLUMNS,
    TOPCOUNT
    {[SR Problem].[PROBCODE].[PROBCODE].
    MEMBERS},
    10,
    [Measures].[SRCOUNT]
    ON
    ROWS
    FROM
    [SR and WO Cube]

  • 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 Insert Syntax erro !!! please help

    I am getting an a Syntax Error
    Sending query: INSERT INTO Customer (custNo, name, address, date) VALUES ('3001005', 'John Ped', '32 Lake st La', '05/07/2004')
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    Any clues to this problem would be very helpful ....
       if ( !fields.custNo.getText().equals( "" ) &&
                  !fields.name.getText().equals( "" ) ) {
                  String query = "INSERT INTO Customer (" +
                   "custNo, name, address, date" +
                   ") VALUES ('" +
                   fields.custNo.getText() + "', '" +
                   fields.name.getText() + "', '" +
                   fields.address.getText() +"', '"+
                   fields.startDate.getText() + "')";

    Anybody who uses "DATE" for a column name is asking for trouble. First of all, it's a keyword. Second, it's vague. Is it the customer's birthday? The day they were entered into the system? Change that column name to something more descriptive and not a keyword.
    You'd also be much better off using PreparedStatement. It'll escape all those Strings and Dates for you properly.

  • Sql loader syntax issue

    SQL*Loader: Release 11.1.0.7.0 - Production on Thu Mar 18 07:21:37 2010
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    SQL*Loader-350: Syntax error at line 1.
    Expecting keyword LOAD, found "ÐÏ".
    ÐÏࡱá
    ^
    My sqlldr file looks like this:
    sqlldr control=C:\data\ctl\ss.ctl log=C:\data\logs\ss.log userid=User/Password errors=999 discard=C:\data\discard\ss.dis
    control file looks like this:
    LOAD DATA
    INFILE 'C:\data\SS.TXT' "STR '\r\n'"
    REPLACE
    INTO TABLE SS
    FIELDS TERMINATED BY ';'
    TRAILING NULLCOLS
    ACCOUNT_NBR CHAR,
    ADDR1 CHAR,
    ADDR2 CHAR,
    ADDR3 CHAR,
    ADDR4 CHAR,
    CITY CHAR,
    STATE CHAR,
    ZIPCODE CHAR ,
    more columns all of the are the same syntax column name and char
    I can load this table using the enterprise manager but when using the sqlldr its not working.
    Anything stand out?
    Edited by: mlojan on Mar 18, 2010 5:33 AM

    Only thing I can think of is there is some character set issue between the control file and the operating syste/oracle server.
    You did you create the control file using a text based editor such as notepad or wordpad didn't you? You haven't used something like MS Word?

  • 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.

  • SQL Trim Syntax required

    Hi All,
    I need help on the syntax of the trim function in SQL.
    My query is like the following:
    select im.item,
    from item_master im,
    The items fetched are like this:
    im.item
    SV122323
    SV122313
    I want to remove the SV so that my query output should be like the following:
    item
    122323
    122313
    Please let me know if you need any clarfications from my end.
    Thanks & Regards,
    Debabrata

    debabratas wrote:
    The items fetched are like this:
    im.item
    SV122323
    SV122313
    I want to remove the SV so that my query output should be like the following:
    item
    122323
    122313If 'SV' always appear at the starting position of the String then you could try something like:
    WITH test_tab AS
         (SELECT 'SV122323' col_1
            FROM DUAL
          UNION ALL
          SELECT 'SV122313'
            FROM DUAL)
    SELECT LTRIM (col_1, 'SV')
      FROM test_tabRegards,
    Jo

  • 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)

  • Help With Dynamic PL/SQL LOV Syntax

    Hello
    I am trying to create a dynamic pl/sql lov in Oracle Apex 3.2 on 11g. I am having some issues with the syntax of the statements below and I'd appreciate any suggestions.
    DECLARE
    BEGIN
    IF :p3_current_a_workshop != 0 THEN
    RETURN
    'select distinct workshop_title ||':  '  || presenter_name ||'    $'|| workshop_fee display_value, workshop_id return_value
    from WORKSHOP
    where session_time = 'A'
    and workshop_status = 'Open'
    or workshop_id = :p3_current_a_workshop
    order by 1';
    ELSE
    RETURN
    'select distinct workshop_title ||':  '  || presenter_name ||'    $'|| workshop_fee display_value, workshop_id return_value
    from WORKSHOP
    where session_time = 'A'
    and workshop_status = 'Open'
    order by 1';
    END IF;
    EXCEPTION
            WHEN OTHERS THEN
                HTP.PRN('ERROR'||SQLERRM);         
    END;I am trying to model the above code off of the example given by apex:
    A function that returns a SQL query with two columns:
    IF :MY_ITEM='10' THEN
      RETURN
      'SELECT ename, empno
    FROM  emp
    WHERE depno = 10
    ORDER BY 1';
    ELSE
      RETURN
      'SELECT ename, empno
    FROM emp
    WHERE depno = :my_item
    ORDER BY 1';
    END IF;~Andrew Schultz

    Hi Andrew,
    Try something like:
    DECLARE
    BEGIN
    IF :p3_current_a_workshop != 0 THEN
    RETURN
    ' select distinct workshop_title ||'':  ''  || presenter_name ||''    $''|| workshop_fee display_value, workshop_id return_value '||
    ' from WORKSHOP '||
    ' where session_time = ''A'' '||
    ' and workshop_status = ''Open'' '||
    ' or workshop_id = :p3_current_a_workshop '||
    ' order by 1 ';
    ELSE
    RETURN
    ' select distinct workshop_title ||'':  ''  || presenter_name ||''    $''|| workshop_fee display_value, workshop_id return_value '||
    ' from WORKSHOP '||
    ' where session_time = ''A'' '||
    ' and workshop_status = ''Open'' '||
    ' order by 1 ';
    END IF;
    EXCEPTION
            WHEN OTHERS THEN
                HTP.PRN('ERROR'||SQLERRM);         
    END;Regards,
    Lev

Maybe you are looking for

  • How to update changed data in alv grid.

    hi experts, i have a editable alv report how to update the changed data on the grid to database table when i click save. can anybody tell me how to do this if possible with example. thanks in advance. regards, venu

  • Duplicate Function Modules

    This is quite a complicated problem and Iu2019ve tried to simplify a bit. I created a custom FM (Z_FM_1) in a custom function group. When I try to activate it, I get a syntax error u201CINCLUDE  LZRB1$11 - A function already exists with the name Z_FM

  • Why I cannot open "Domain. sites"

    I have two domains Domain.1 and Domain.2 parked in the iWeb folder. After I publish one page and go back to open iWeb the following window pops up: The document "Domain sites" is invalid the index.xml is missing iWeb can't open file: "Library/Applica

  • All urls won't start in firefox when clicking on them in thunderbird

    When in Thunderbird 9.0.1, I click on a link to be opened in Firefox nothing happens. I have to copy the link location, go to Firefox and paste and go, to open the webpage.

  • Trouble importing a Pagemaker file into CS 5.5

    I am VERY new to ID 5.5 (today is my first day). I m trying ID because it is supposed to import Pagemaker files So in my first attemp to open a PM6 file it fails. But i'm so new I dont even know who to 'point the finger at'. The non-working symptom i