Why is this php sql wrong?

hello
i have wrote this code:
$sql = "select a.Name,  (select sum(b.Points) as tpoints from Points_Table b group by b.Name order by tpoints limit 10 ) as TotalPoints
from Points_Table a, Points_Table b
where a.Name = b.Name
group by a.Name
order by TotalPoints desc, a.Name";
basically, this is for a league table. i am trying to extract a name, and the total of ten best scores from a list of 15 for each name.
the above code is not working. any ideas?
what should it look like?

In Oracle, the empty string is equivalent to NULL.
Any condition other than IS NULL or IS NOT NULL, when applied to NULL, returns NULL, which gets evaluated to FALSE in an IF statement.
So
IF( someVariable = NULL )will always be FALSE. As will
IF( someVariable != NULL )You would have to use
IF( someVariable IS NULL )in order to get the condition to evaluate to TRUE.
Justin

Similar Messages

  • What is the wrong in this PL/SQL  block

    Hi a...
    Can you please tell what is the wrong in this pl/sql block.
    declare
    TYPE TYP_NT_NUM IS TABLE OF NUMBER ;
    v_tab TYP_NT_NUM := TYP_NT_NUM();
    TYPE uname is VARRAY(30) of varchar2(100) ;
    usr uname := uname ( 'u1','u2','u3','u4' );
    TYPE pwd is VARRAY(30) of varchar2(100) ;
    psw pwd := pwd('p1','p2','p3','p4');
    x number(10):=0;
    Cursor fcid IS Select distinct FC_ID From FCMASTER ;
    Begin
    Open fcid ;
    --for ii in usr.first .. usr.last loop
         Loop
              Fetch fcid Into x ;
              Exit When fcid%NOTFOUND ;
              v_tab(fcid%ROWCOUNT) := x ;
         End loop ;
         For iii IN v_tab.FIRST .. v_tab.LAST Loop
              dbms_output.put_line(v_tab(iii).FC_ID) ;
              End loop ;
    End loop; End of outer loop
    End;
    The error is
    Error
    [row:28,col:36] ORA-06550: line 28, column 36:
    PLS-00487: Invalid reference to variable 'NUMBER'
    ORA-06550: line 28, column 4:
    PL/SQL: Statement ignored
    Thanks in advance,
    Pal

    v_tab(iii).FC_ID
    declare
      type typ_nt_num is table of number;
      v_tab typ_nt_num;
    begin
      select distinct object_id bulk collect into v_tab from all_objects where rownum <= 10;
      for i in 1 .. v_tab.count loop
        dbms_output.put_line(v_tab(i)) ;
      end loop ;
    end;
    /

  • What is wrong with this PL/SQL

    sqlplus -s enbref10/enbref10@q4enbdb << END_SQL
    set serveroutput on size 200000
    set feedback off
    DECLARE
    tableName VARCHAR2(40);
    ddl VARCHAR2(4000);
    rows NUMBER(4);
    BEGIN
    BEGIN
    SELECT TNAME INTO tableName FROM TAB WHERE TNAME = 'PC_EXTRACT_CURRENT';
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('Creating table PC_EXTRACT_CURRENT');
    ddl := 'CREATE TABLE PC_EXTRACT_CURRENT ( OFFER_ID NUMBER, TLG_SOC CHAR(10 BYTE), CPW_CODE CHAR(10 BYTE),
    OFFER_NAME CHAR(100 BYTE), OFFER_DESCRIPTION CHAR(100 BYTE), OFFER_TYPE CHAR(50 BYTE), OFFER_LEVEL CHAR(20 BYTE),
    SALES_EFFECTIVE DATE, SALES_EXPIRATION DATE, PACKAGE_ID NUMBER, PACKAGE_NAME CHAR(100 BYTE),
    PACKAGE_QUALIFICATION CHAR(100 BYTE), PRIT_ID NUMBER, ITEM_ROLE CHAR(10 BYTE), ITEM_NAME CHAR(100 BYTE),
    CHARGE_CODE CHAR(20 BYTE), PRIORITY NUMBER, PRIT_QUALIFICATION CHAR(100 BYTE), UOM CHAR(20 BYTE),
    QUOTA1 CHAR(15 BYTE), RATE CHAR(10 BYTE), NAME CHAR(100 BYTE), TLG_MARKETS CHAR(100 BYTE),
    OFFER_RELATION_TYPE CHAR(5 BYTE), OFFER_RELATION_ID NUMBER, OFFER_TYPE_IND CHAR(5 BYTE))' ;
    execute immediate DDL ;
    END ;
    SELECT count(*) INTO rows from PC_EXTRACT_CURRENT ;
    END ;
    exit ;
    END_SQL
    When i run this PL/SQL it gives me below error...
    SELECT count(*) INTO rows from PC_EXTRACT_CURRENT ;
    ERROR at line 23:
    ORA-06550: line 23, column 36:
    PL/SQL: ORA-00942: table or view does not exist
    ORA-06550: line 23, column 5:
    PL/SQL: SQL Statement ignored
    Table PC_EXTRACT_CURRENT do not exist and it should be created in the EXCEPTION block and the following statement " SELECT count(*) INTO rows from PC_EXTRACT_CURRENT ; " should not give any error.
    But the table is not created and the this statement fails when executed.
    I have no clue why it is happening .
    When i comment the line "SELECT count(*) INTO rows from PC_EXTRACT_CURRENT " it creates the table.

    This code would give compilation error at the
    following statement, if this table doesn't exist.
    SELECT count(*)
    INTO rows
    From SCHEMA.PC_EXTRACT_CURRENT;
      SELECT count(*)
        INTO vCount
        FROM ALL_TABLES
       WHERE table_name = 'PC_EXTRACT_CURRENT'
         And owner      = 'SCOTT';that is why you have this above code to check for the existence of the table for the same schema owner, assuming you are running this code logged to the database as SCOTT. this SCOTT schema is hardcode in replacement to the SCHEMA posted in the prior posted example. suppose the schema owner is SCOTT so we are checking the SCOTT.PC_EXTRACT_CURRENT object. now it does not found the object and it will result in vCount having a value of 0. then we go down to the next logic of the IF Then Else statement. It will execute the code under the IF vCount = 0 which is execute immediate to create the table.
    on the second time the script is run vCount will give you 1 value. now the when it goes to the IF then Else statement it will execute the code under the Else since vcount has a value of 1. then it does a query as
        SELECT count(*)
          INTO rows
          From SCOTT.PC_EXTRACT_CURRENT;we have the object SCOTT.PC_EXTRACT_CURRENT and this will not give you error since the object is existing.

  • TS1470 can not purchase anything because it says my bank details are wrong why is this ?

    can not purchase anything because it says my bank details are wrong when they are not why is this ?

    I found a question similar to mine and got it resoved, but thank you anyway

  • When I select a photo from photo library, the wrong picture displays.  Why is this happening?

    When I select a photo from the Photo Library, the wrong picture displays.  I'm unable to find the picture selected, making it very difficut to apply wall paper or to contacts.  Why is this happening?

    I restarted the phone and forced the app to close and neither resolved the issue.  I then had the bright idea to remove the sync of photos and remove all the photos from the device.  I checked the Photos app and it was empty.  I then synced again with the photos selected and all the pictures were restored.  The photo library now displays the photo I select.

  • Why have iTunes charged my account when I've got a £20 voucher on my account and the. Had to arrange a call back what was 2 days ago they called me back tonight then said the department was closed this is a wrong I want my money back!

    Why have iTunes charged my account when I've got a £20 voucher on my account and the. Had to arrange a call back what was 2 days ago they called me back tonight then the automated voice said the department was closed this is a wrong I want my money back! Or I'm gonna sell my iPad my kids iPods and iPhones mine and my wife's iPhones and the mac this is a **** take

    We are fellow users here on these forums, you are not talking to iTunes Support nor Apple.
    Were you buying content for yourself or gifting to another account ? If you were gifting content or an amount then that can only be done via credit card). If you weren't then you will need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • Why does this message keep appearing when i try to instal windows 7 through bootcamp? - "something went wrong and the USB cannot be configured for the installation"

    Why does this message keep appearing when Itry to instal windows 7 through bootcamp? - "Your bootable USB drive could not be created. An error occurred while copying the Windows installation files."

    Found a solution!
    Follow the extended version of these directions here:
    https://discussions.apple.com/docs/DOC-3581
    Worked like a charm!

  • Since mountain lion Find in Numbers 3-4 columns of data missing and some columns in the wrong order. Fortunately I have a back up on my iPad and was able to put that version in as a new file. Why has this happened ?

    Since mountain lion I have noticed 3-4 columns of data missing from a Numbers file. I have fortunately been able to replace the total file from my iPad version but why has this happened. Makes me lose trust in Numbers

    That would be strange.

  • Is this sql wrong????

    select accID, transactionDate,SUM(dr) As sumofdr,SUM(cr) As sumofcr from too;

    Come on, several people have allready answered to this question when you first posted this to a wrong forum. They also gave you some good pointers on how to ask better questions. Please don't post the same question repeatedly to different forums..
    http://forum.java.sun.com/thread.jsp?forum=31&thread=509283&tstart=120&trange=15

  • How to Update this T-SQL Table?

    Hello,
    I am having trouble finding the correct syntax for updating this T-SQL table.
    Here is my Query which is adding an additional ' at the beginning and end.
    Query:
        Update [denodo].[dbo].[wrappers]
      SET wrapperWhereClause = '''AND County_Input=''Cheyenne & Arapaho Tribal Court'' AND WrapperID=729'''
      WHERE wrapperID = '729'
    The Outcome:
    'AND County_Input='Cheyenne & Arapaho Tribal Court' AND WrapperID=729'
    The Outcome I am hoping for:
    AND County_Input='Cheyenne & Arapaho Tribal Court' AND WrapperID=729
    Can anyone help me edit this so I can receive the outcome I am hoping for?

    >> Please learn
    I am having trouble finding the correct syntax for updating this T-SQL table. Here is my Query [sic] which is adding an additional ' at the beginning and end. <<
    Please learn basic terms so
    we can communicate. UPDATE is a statement and not a query. You do not know ISO-11179 rules, etc.
    Why are you building statements in SQL? You are doing bad SQL programming
    and need to stop. Your silly meta-data “wrapper_where_clause” and “county_input” is so fundamentally wrong I would fire you. Look at what I have done
    with SQL and see what a criticism that is!
    UPDATE Wrappers
    SET ??
    WHERE county_something =
    'Cheyenne & Arapaho Tribal Court'
    AND wrapper_id = '729';
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Why a simple php syntax checker extension doesn't exist yet for Dreamweaver CS4 ?

    Hello,
    my request is in the subject ;-)
    I remember a very useful extension in Golive CS8/9 that did exactly that :
    Duplicate from DW the currently edited php/html page to a temp file
    Send the temp file to the command line : "/path/to/php -l /path/to/temp/file"
    Display the command output ("syntax ok" or "error on line ##") directly INSIDE dreamweaver
    It required only that an apache/php package was installed on the developer's computer (using whater Xampp, or Wamp, etc.)
    Though you might say to me that I should use a PHP IDE wich is dedicated specifically to that goal, I wonder why a such extension does not exist... as it is a great time saver when rapid syntax checking is required before uploading...
    I may be wrong but i can't find anything close to that via google / adobe studio exchange search results...
    Should I start to learn the dreamweaver CS4 API extension documention or someone can give me a hint to achieve that ?
    Thanks everyone.

    Hi M.Zografski
    I have tried to clear that cache the only thing I keep running into is that the file that is listed doesn't even match the way my dreamweaver loaded onto my computer. I get up to the point of the Adobe file then my next one is shown as Adobe Dreamweaver CS4- I choose this and then there is no file in there showing the language at all. I have a file listed as %AppData% and if I choose this one then it shows Thinstall file and this opens into Adobe AIR- then this has some registry files and another fold as %drive_C% which opens to Adobe then to Dreamweaver then to en_US then Configuration which does contain a file RDSINFO and it appears to be empty. This seems very round about to getting to the cache file and I was unsure of whether or not this was what I was indeed looking for.  Also if I try to search for this WinFileCache with that file name I get no results.
    Why is this being so stubborn. I am thinking if I could locate the file then it would all go well
    Thanks
    Teresa

  • My iphone is suddenly populated by random songs I've downloaded in the past. Why does this happen, and what are apple doing about fixing this?

    Why does this happen?
    What do other people do? (I can't go to sleep knowing there's a rogue album or song in my music. It's 2am now)
    What do we tell apple so that they actually fix it. None of us want to pay £25 to have our own music.

    I am on the monthly payment plan because nobody at BT has told me there is any alternative!
    Each year there I have a long, in-depth conversation with the person who sets up the contract for the next year but the gist of the thing is 'I'm  not going to be paying more than [x amount] per month, am I? Because I can't afford any more'' and each year the person says that no, in fact I should be paying less... and then without notice and even with the bill saying 'We will continue to take....' a totally different - and higher - sum disappears from my bank account.
    Then I go through the painful process of writing to complain about this, get some sort of sum refunded and then the payments go through at the level they should, with me paying any additional (usually small) amounts for usage over the allowance. Until contract end when we start all over again...
    Even if the amount they seem to randomly decide on is based on some sort of forecast, this should not be happening as I am doing what they instruct me to do on the bill to keep my payments the same.
    So something is going wrong, on many levels.
    At no point have I been offered the sort of 'monthly billing' described here; maybe there is some reason I am not allowed it. Unfortunately 'whole bill' direct debit payment is beyond me. I really need to know what I will be paying each month and I need BT to correctly take that amount, as agreed, each month, from the get-go.
    It shouldn't be that hard really! Does anyone from BT read these forums? Can somebody take this on and finally get this straight, please?

  • My iphone consumed  10GB data this what's wrong with my VPN kindly guide suitably moreover battery drain fast

    My iphone 5s consumed  10GB data this what's wrong with my VPN kindly guide suitably moreover battery drain fast

    The long backups seem to be related to the size of the apps you installed, not the number. That's why some people with multiple pages of apps experience fast backups. There does seem to be a bug with the current firmware that can cause a crash when doing app uploads and syncs. This bug seems to be exacerbated by having large and many apps.
    I was experiencing frequent crashes, but have no more - even with 70 apps installed - some of them large like the American Heritage Dictionary which is several hundred megabytes. I did the following:
    1. I set iTunes to NOT do autosyncs every time I plug in. This setting is in the Itunes preferences.
    2. I disabled the autobackups in iTunes for the iphone. I figured that if it did crash and it was going to take 2 hours to restore, why not just reload. The instructions are readily found using google search; it involves a command line setting. Anyway, the phone doesn't crash anymore since doing this.
    3. I no longer install apps using the iPhone. I first install the app in iTunes and the I manually sync it to the iphone. I avoid doing multiple installs at once; at least for the large apps. Right click on each app and get its info from within itunes. If it is large, it is going to take time to backup.
    4. I always first shut off the iphone and restart it before installing any apps in itunes. This clears any memory issues left behind from use.
    I am going to continue to do these procedures until Apple releases a fix for the bugs relating to the apps.
    As noted, since I took these steps, I have had no crashes. I was crashing at least once every 1-2 days before with the same or less number of apps. I too was a first gen iPhone user and was very frustrated with the 3G experience. Since doing the above, I am once again a very happy and productive iPhone 3G user. I know its a pain to do this, but the bugs will get fixed at some point. I would never go back to my old phones - they were just phones.

  • Why does my php export feature work in IE and not firefox?

    Why does my php export feature work in IE and not Firefox? I've written a web application which contains a SigmaGrid. The grid controls reload, add update delete, print and export to csv all work in IE8. The export feature does not work in Firefox.

    I'm not sure what's going on for you. I've had 4 other developers - two on Comcast and two on Fios review my work and they get the control and export action in the IE8 version but not the FF10 version.
    Thanks for looking into this for me, though. I appreciate the effort. '' The operation was a success doctor, but the patient died.''

  • Why is this session not connecting to the preferred Instance ?

    Grid Infrastructure/DB Version : 11.2.0.3
    Platform : RHEL 5.8
    We have a 3-node cluster and I've configured the RAC service PKDS_UAT_01 with its preferred instance as JDSCFS3
    $ srvctl config service -s PKDS_UAT_01 -d JDSCFS
    Service name: PKDS_UAT_01
    Service is enabled
    Server pool: JDSCFS_PKDS_UAT_01
    Cardinality: 1
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: false
    Failover type: NONE
    Failover method: NONE
    TAF failover retries: 0
    TAF failover delay: 0
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: NONE
    Edition:
    Preferred instances: JDSCFS3
    Available instances: JDSCFS1
    Then I start a remote session through SQL*Plus like
    sqlplus scott/tiger@rtfms-scan:1624/PKDS_UAT_01.acproot.net
    When I check in the DB, it shows that the session is actually connected to instance 1 despite the preferred instance set as Instance3 (JDSCFS3) for the service PKDS_UAT_01
    SQL> select inst_id, sid from gv$session where username='SCOTT';
       INST_ID        SID
             1       3839
    Why is this happening ?

    1. check that all services are running on all nodes. Actually, you service should run only on preffered node
    srvctl status service -d db_name
    2. restart services
    3. try again
    Regards
    Ed

Maybe you are looking for

  • How can i use page break for every 5 records in sap scripts

    on every 5 lines of records i have go for a new page so what is procedure to do this .if possible send me with coding .

  • Help:i need a code for making a new text file then adding 1 blank line

    i have done makng load, edit and save for a command line text editor. now my problem is, i dont know how to make a new blank text file and store it on the current directory. and i need to have that new text have 1 blank line with full of white space.

  • 5530 XM would not connect to wifi

    I just got my new nokia 5530 XM yesterday, and I've been trying to connect to wifi since i got it, but it would just not connect. it does detect my WLAN but after I enter the "Pre-Shared key" it says "unable to connect, WLAN not found" I already try 

  • Query in portal

    Hi I have  a query with free characteristics which enabled my reprot with the drill down. i want to publish in the portal , i know how to publish it. Now my question is 1) if create a webtemplate and publish will it have the that Drill Down functiona

  • Extracting date without time from getObject() result

    I use following code to get the date from sql table, which uses object types: oracle.sql.STRUCT os = (oracle.sql.STRUCT)rset.getObject (1); Object a[] = os.getAttributes(); columns.addElement(a[0]); I am getting both date and time. What can I do to e