HELP - SQL and Select and COUNT

Hi Anyone or Everyone...
I have created this SQL Statement in java
SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'C%' GROUP BY #PART ORDER BY #PART
this is the error I get....If I remove the Count(#PART) works fine so the column #PDESC is fine....what is wrong with this?? Thanks in advance!!
[SQL0122] Column #PDESC or expression specified in SELECT list not valid.

Hi Anyone or Everyone...
I have created this SQL Statement in java
SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB
WHERE #PART LIKE 'C%' GROUP BY #PART ORDER BY #PART
this is the error I get....If I remove the
Count(#PART) works fine so the column #PDESC is
fine....what is wrong with this?? Thanks in advance!!
[SQL0122] Column #PDESC or expression specified in
SELECT list not valid.Hi there
When you are querying on a table, either you have to specify individual elements (columns) of the table or aggregations of the columns. In your case, the elements you are querying are : #PART, #PDESC and PCOUNT. Here, PCount is an aggregation that is calculated form COUNT(#PART) and #PART is also an aggregation as you are grouping the query results by #PART. But, What bout #PDESC? You are querying as individual column only and doing nothing with it. That was the problem.
Tip: Try adding "GROUP BY #PDESC" or "COUNT(#PDESC)" to your query and I hope it shud work.
May be It won't solve your problem and give the result that you need, but you will understand the point I am trying to explain.
Cheers
-Uday

Similar Messages

  • Query: how to use structure and selection and what's the difference between

    Query: how to use structure and selection and what's the difference between these two?
    Would be appreciated if some experts here give examples to demenstrate on how to use structure and selection in query and what's the difference between these two?
    Thanks in advance!

    Hi Kevin,
    1. Well by default all the KF that you include in your query go into a Key Figure Structure. You can additionally have another structure for defining how your chars are laid out. A common example is a Calmonth structure where you have selections for 12 months, quarers and YTD values. This would be a char structure with different selections (for each month, qtr etc)
    2. Yes, a selection with a KF is the same as restricting a KF. You can use am RKF is you have one on the left hand side, or if you need to do this locally in the query, right click the structure and choose New Selection, then proceed to choose your KF and reqd char values.
    Hope this helps...

  • How can I select more than one bookmark at a time so that I can then open multiple bookmarks -- without the aggravation of going back to the list and selecting and opening each one.

    From my dozens of bookmarks, I often would like to open 5 or 6 of them at once -- perhaps a couple of weather reports, a couple of radio stations, a couple of other websites. But I see no way of doing this without laboriously finding a bookmark, selecting it, opening the website, then returning to the bookmarks, finding the second bookmark, selecting it, opening the website, and on and on. Surely there's a way for me to select multiple unrelated bookmarks and open them at the same time. Thanks much for your help. Don

    ''Actually there is a picture and better explanation in the corresponding History article''
    * ''http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox ''
    Look where this picture is embedded in the article topic [http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox#Selecting_history_items Selecting history items]
    * http://kb.mozillazine.org/images/Fx3_history_sidebar_selections2.png
    Selecting, viewing, and searching the sidebars and library lists is explained in both articles previously mentioned.
    Multiple selection is something built-in to a lot of applications and into all browsers, and yes you guessed correctly the favicon it the thing to the left of the bookmark and that is what is is called in all browsers. And if you look at selection you will find that it matches what you asked for, especially if you were to do a search from the search bar on the bookmark or history sidebar. But there is also no problem opening up a single bookmark or history item into a new tab, with either Ctrl+click or Ctrl+Shift+click in the area to the right of the favicon either.
    However I would suggest making a change to your configuration options so the the same keyboard shortcut is used from a link and from your bookmarks. See those keyboard shortcuts in the following along with the footnotes just below the table for them in
    * http://www.mvps.org/dmcritchie/firefox/keyboard.htm

  • Help with Webcam selection and setup

    Hi, I need to set up a webcam for my Emac. What do you suggest in buying and do I use IChat or my son wants to use Skype. How do you set the whole deal up. Thanks, John

    Since you have brought a New Computer and connected the Adapter to the computer, whats the OS installed on your Computer? Have you installed the drivers for your adapter on your computer?
    Well you can download the software from the Linksys website.

  • Help with Droid Selection and also travel to Canada?

    I am being given a choice between the Samsung Stratosphere, the Motorola Droid 4, and the HTC Incredible 2. The Stratosphere and Droid 4 are very similar phones. Both have physical keyboards as well as touch screens. The big difference I can see is the Droid 4 has 16GB (double) the memory. Both the Stratosphere and Droid 4 are 4G, but the Incredible 2 is not.
    I travel mostly in the US, but do travel to Canada a couple of times a year. I have been told that the Stratosphere and Droid 4 are domestic only phone and that the Incredible 2 is recommended for international travel.
    1. Will the Stratosphere and Droid 4 work in Toronto ... but reverted to 3G?
    2. Recommendations on a choice between the Stratosphere and the Droid 4?
    Thanks in advance!

    Any 4g phone will work in Canada/Mexico... on CDMA (3g).
    The Stratosphere is a phone from 2010 with LTE bolted on (it's virtually identical to Sprint's version of 2010's Galaxy S, the Epic 4g). The Droid 4 is a RAZR with a keyboard bolted on...
    Droid 4 is the far superior device from a hardware standpoint.
    Either phone is better than the Incredible 2, due to LTE.

  • Help: SQL to select closest points within groups of records grouped by time

    Hi,
    I need help to find an SQL for efficient solution for the following problem:
    - I have 20 buses circling on one bus route and their locations are reported every 10 seconds and recorded into a spatial table “bus_location” with “bus_loc” as SDO_GEOMETRY type.
    - Each bus location record there has a msg_datetime column with the time when the location was recorded.
    - Buses circle the bus route 8-12 times, from A to B, then from B back to A, then new loop from A to B, and so on.
    - I have 3 timing points in spatial table “timing_point” with “tp_loc” as SDO_GEOMETRY type.
    - A bus will pass each timing point 8-12 times in one direction and 8-12 times in the other direction, while making loops on the bus route.
    My task is: for each timing point, for each bus, for each trip direction (A-B or B-A), find the closest bus location to that timing point.
    Example:
    Bus...*TimingPoint*......*Time*.....*Distance*
    ...........................................*between*
    ...........................................*bus and TP*
    12......A................14:01:00......250 m
    12......A................14:01:10......150 m
    12......A................14:01:20......12 m <== This is the record closest to the TP for this pass
    12......A................14:01:30......48 m
    12......A................14:01:40......100 m
    12......A................14:01:50......248 m
    12......A................14:29:40......122 m
    12......A................14:29:50......72 m
    12......A................14:30:00......9 m <== This is the record closest to the TP for this pass
    12......A................14:30:10......10 m
    12......A................14:30:20......12 m
    I tried to use SDO_NN and I can get closest bus locations, but how to find the closest bus location for each pass? Or how to identify a groups of bus locations which are together within 2-3 minutes and to find closest record for each of these groups of locations?
    Thank you very much for any help.
    Milan
    Edited by: mburazor on 9-Feb-2012 2:41 PM

    Milan,
    Yes, the problem is one of analytics not spatial. Here is another go that should be independent of year/month/date/hour/minute
    as it does all its math based on an absolute number of minutes since 1970. I round to 5 minutes but you could round/trunc to any
    particular interval (5 minutes, 10 minutes, 15 minutes etc)
    Note that I have created extra records in the same table that I built. (Tip: good idea to provide a sample dataset to the forum when
    asking difficult SQL questions like this.)
    drop table buslocns;
    create table buslocns(
    busno number,
    timingpt varchar2(1),
    pttime   timestamp,
    distance number)
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:01:00','YYYY/MM/DD HH24:MI:SS'),250);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:01:10','YYYY/MM/DD HH24:MI:SS'),150);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:01:20','YYYY/MM/DD HH24:MI:SS'),12);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:01:30','YYYY/MM/DD HH24:MI:SS'),48);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:01:40','YYYY/MM/DD HH24:MI:SS'),100);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:01:50','YYYY/MM/DD HH24:MI:SS'),248);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:29:40','YYYY/MM/DD HH24:MI:SS'),122);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:29:50','YYYY/MM/DD HH24:MI:SS'),72);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:30:00','YYYY/MM/DD HH24:MI:SS'),9);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:30:10','YYYY/MM/DD HH24:MI:SS'),10);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:30:20','YYYY/MM/DD HH24:MI:SS'),12);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:59:40','YYYY/MM/DD HH24:MI:SS'),53);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:59:50','YYYY/MM/DD HH24:MI:SS'),28);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 15:00:00','YYYY/MM/DD HH24:MI:SS'),12);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 15:00:10','YYYY/MM/DD HH24:MI:SS'),73);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:44:40','YYYY/MM/DD HH24:MI:SS'),53);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 14:44:50','YYYY/MM/DD HH24:MI:SS'),28);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 15:45:00','YYYY/MM/DD HH24:MI:SS'),12);
    insert into buslocns values (12,'A',to_timestamp('2012/02/10 15:45:10','YYYY/MM/DD HH24:MI:SS'),73);
    commit;
    with tensOfMinutes as (
    select row_number() over (order by busno,timingpt, pttime) as rid,
           busno,
           timingpt,
           pttime,
           round(((cast(pttime as date) - cast('01-JAN-1970' as date)) * 1440) / 5) * 5 as mins,
           distance
      from BUSLOCNS
    select busno,timingpt,to_char(to_date('01-JAN-1970','DD-MON-YYYY') + ( mins / 1440 ),'DD-MON-YYYY HH24:MI:SS') as pttime,minDist
      from (select busno,timingpt,mins,min(distance) as minDist
              from tensOfMinutes a
             group by a.busno, a.timingpt, a.mins
             order by 1, 2, 3 ) ;
    -- Result
    BUSNO                  TIMINGPT PTTIME               MINDIST
    12                     A        10-FEB-2012 14:00:00 12
    12                     A        10-FEB-2012 14:30:00 9
    12                     A        10-FEB-2012 14:45:00 28
    12                     A        10-FEB-2012 15:00:00 12
    12                     A        10-FEB-2012 15:45:00 12regards
    Simon

  • Help, I installed parallel and windows, and opened videos (on an external hard disk) with windows, and now cannot open them with Mac, and use i movies.  How do I reverse this?

    Help, I installed parallel and windows, and opened videos (on an external hard disk) with windows, and now cannot open them with Mac, and use i movies.  How do I reverse this?

    Paragraphs help the reader, just saying.
    What are you actually trying to do? Why do you need "DVD size" folders if you're creatng an Archive on an external hard drive?
    Also, I understand burning folders instead of individual photos or albums gives you more space on a DVD.
    It makes no difference at all.
    How can I keep the captions on my photos (not events) when I print or transfer to a new folder?
    You can export while writing the metadata to the file in most cases.
    Tne only way I know is to copy photos from the Windows to folders on my HD, then copy and paste photos or albums or events to HD, then create a new folder and fill it to the appropriate DVD size. 
    HD? Another HD? You use HD there in a way that makes no sense. What's the point of 'DVD size'?
    I also thought I should download future photos to my Canon programming that comes with EOS cameras and edit and then decide which photos to save to iPhoto library and which to save only to my archival HD?
    Does this have any relation to the previous questions? You know you can delete from iPhoto, right?
    You're somewhat confused and you need to
    1. Decide what exactly you want to do
    2. Then go about it.
    If I understand you correctly - and there's no guarantee that I do -  the easiest thing is to bring all your Photos into iPhoto and do everything from there.
    You can have an archive on an external disk, you can sort and select and edit with or via iPhoto
    Regards
    TD

  • Insert, Case and Select

    I try to do one insert with case and select and I can't, I don't know why:
    This is what I want
    I have one column in the TAUX_MEDIA_PPM named GRAU. IF GRAU = 'TIPO', the I have to do one type of INSERT, if is = 'ATRIBUTO' I have to do another type of INSERT and ELSE, another type of INSERT.
    This is what I tested for the last time:
    SELECT T1.GRAU,
    CASE
    WHEN T1.GRAU = 'TIPO' THEN
    INSERT INTO TF_MEDIA_PPM__TESTE (
    MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
    PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
    TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
    ) VALUES (
    SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, T2.MEDIA, T2.ALERTA, T2.ATENCAO, NULL,
    0, 0, 0, NULL, 0, 0, 0
    WHEN T1.GRAU = 'ATRIBUTO' THEN
    INSERT INTO TF_MEDIA_PPM__TESTE (
    MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
    PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
    TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
    ) VALUES (
    SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, 0, 0, 0, NULL,
    T2.MEDIA, T2.ALERTA, T2.ATENCAO, NULL, 0, 0, 0
    WHEN T1.GRAU = 'ATRIB_COMPL' THEN
    INSERT INTO TF_MEDIA_PPM__TESTE (
    MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
    PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
    TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
    ) VALUES (
    SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, 0, 0, 0, NULL,
    0, 0, 0, NULL, T2.MEDIA, T2.ALERTA, T2.ATENCAO
    END
    FROM TAUX_MEDIA_PPM
    JOIN TX_MEDIA T2 ON T2.CHAVE = T1.CHAVE;
    I don't know what I have to do now...
    Regards,
    Tiberio
    Edited by: MrTiberio on 27/03/2012 06:55
    Fixing code formatting

    I used this:
    INSERT INTO tf_media_ppm__teste
    (media_ppm_seq,data_sk,escopo_sk,motivo_sk,periodo_tipo,media_ppm_tipo,tres_sigma_tipo,seis_sigma_tipo,periodo_atributo,media_ppm_atributo
    ,tres_sigma_atributo,seis_sigma_atributo,periodo_atribcompl,media_ppm_atribcompl,tres_sigma_atribcompl,seis_sigma_atribcompl)
    SELECT seq_tf_media_ppm.nextval,t2.data_sk,t1.escopo_sk,t1.motivo_sk,NULL
    ,CASE t1.grau WHEN 'TIPO' THEN t2.media ELSE 0 END
    ,CASE t1.grau WHEN 'TIPO' THEN t2.alerta ELSE 0 END
    ,CASE t1.grau WHEN 'TIPO' THEN t2.atencao ELSE 0 END
    ,NULL
    ,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.media ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.alerta ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.atencao ELSE 0 END
    ,NULL
    ,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.media ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.alerta ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.atencao ELSE 0 END
    FROM TAUX_MEDIA_PPM T1
    JOIN TX_MEDIA T2 ON T2.CHAVE = T1.CHAVE;
    and worked fine.
    Thanks for both of you !

  • Select and Count not working.....HELP PLEASE!!

    I have the following scenerio:
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //brings back count of 1 which is right...only one part within the date range
    PCOUNT: 1
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AC043208%' OR #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //looped through result set and these two counts are right
    PCOUNT: 1
    PCOUNT: 1
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' OR #PART LIKE 'AC043208%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //now brings back a pcount of 2 for the first part which is shouldn't, there are two parts with the same number but only one which falls within the date range.
    PCOUNT: 2
    PCOUNT: 1
    could anyone help me with this.....thanks in advance

    Found the solution....its in the order of processing of the select statement...for others future reference....
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //brings back count of 1 which is right...only one part within the date range
    PCOUNT: 1
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AC043208%' OR #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //looped through result set and these two counts are right
    PCOUNT: 1
    PCOUNT: 1
    //*****this works because in actual fact it is reading the date range and it associates it with the last part number so it reads it like this (note the brackets):
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AC043208%' OR (#PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826) GROUP BY #PART,#PDESC
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' OR #PART LIKE 'AC043208%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //now brings back a pcount of 2 for the first part which is shouldn't, there are two parts with the same number but only one which falls within the date range.
    PCOUNT: 2
    PCOUNT: 1
    //***this did not work because the date range only applied to the last part number not the first..so it read it like (note the brackets):
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' OR (#PART LIKE 'AC043208%' AND #RECDT BETWEEN 19970826 AND 20020826) GROUP BY #PART,#PDESC
    //**Therefore, I changed it to (including the brackets) and it ran fine:
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE (#PART LIKE 'AN101011%' OR #PART LIKE 'AC043208%') AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC

  • HELP , SQL-AND

    Hi everyone:
    Here i have a table:
    create table cap_binding (
    test_ser_id NUMBER(10) not null,
    test_cap_id NUMBER(10) not null,
    cap_binding_id NUMBER(10) not null,
    constraint PK_CAP_BINDING primary key (cap_binding_id)
    insert into cap_binding values(64,21,1);
    insert into cap_binding values(64,1,2);
    insert into cap_binding values(65,1,3);
    now, i want to find out the test_ser_id where the corresponding test_cap_id is 21 AND 1 , and in the given
    data, the result should be the first two records.
    initially, i write: select y.TEST_SER_ID from cap_binding y where y.test_cap_id in (1,21), but the in operator performs OR logic and i get three records.
    I cannot figure out how to write the sql. Could anyone help me?
    Thanks.

    This will work if you have a unique constraint on test_ser_id, test_cap_id:
    with t as (
    select 1 col1 from dual UNION ALL
    select 21 col1 from dual
    select * from (
    select test_ser_id,
           test_cap_id,
           cap_binding_id,
           COUNT(*) OVER (PARTITION BY test_ser_id) cnt
    from cap_binding)
    where cnt = (SELECT DISTINCT COUNT(*) FROM t);
    TEST_SER_ID            TEST_CAP_ID            CAP_BINDING_ID         CNT                   
    64                     21                     1                      2                     
    64                     1                      2                      2                     
    2 rows selectedI used a table using a with clause to store the values we are looking for (1, 21), but you could use a pipelined function or a variable as well.

  • "select count(*)" and "select single *" returns different result

    Good day!
    product version SAP ECC 6.0
    oracle10
    data transfers from external oracle db into customer tables using direct oracle db link
    sometimes I get case with different results from 2 statements
    *mytable has 10 rows
    *1st statement
    data: cnt type I value 0.
    select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *cnt returns 10 - correct
    *2nd statement
    select single * from  mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *sy-dbcnt returns 0
    *sy-subrc returns 4 - incorrect, 10 rows are "invisible"
    but
    1. se16 shows correct row number
    2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
    can not understand why
    thank you in advance.

    Thank you, Vishal
    but,
    general problem is that
    1. both statements have the same WHERE conditions
    2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
    Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
    Dataset to process is the same, WHERE conditions are equal...
    I think the problem is that how ABAP interperets select count(*) and "select single *".
    Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
    I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
    se16 shows all records.
    And why after simple manual update of just one record using se16 "select single *" returns 1?
    I've just marked one row to update, didn't change any data, then pressed "save".

  • SQL Select and From Functions

    Can sql aggregate functions be added to an interface select clause and from clause.
    I want to have a datasource where one of the columns is an aggregate such as a count, which would need the ability to indicate a from clause function group by, or having by. In the Designer Diagram tab for the interface, it seems you can only apply sql functions to where clause joins or filters.
    I want to have a query such as follows as my datasource
    select columnA, count(*) as thecount
    from table x
    group by columnA
    order by thecount asc
    and ultimately
    select columnA, thecount
    from (select columnA, count(*) as thecount
    from table x
    group by columnA
    order by thecount asc)
    where rownum <1001
    Can this be done in the ODI Designer, without creating a physical custom view on the database?

    Hi lpantuso,
    Aggregate functions are added by ODI automatically. In this case you would want mappings like this:
    TARGET_COL_1: columnA
    TARGET_COL_2: count(*)
    ODI will generate something like this:
    select     
       columnA,
       count(*)
    from     MY_TABLE MY_TABLE
    where     
         (1=1)
    Group By MY_TABLE.columnA
    The subselect, however, isn't handled out of the box. In general ODI isn't quite as friendly with ordering clauses since order by is not relational. (Sets aren't ordered.) To get only the first 1000 columnA values, you'll probably need to create a view or break it into 2 separate interfaces.
    Regards,
    Matt

  • Need Help With SQL GROUP BY and DISTINCT

    I am working on a project and need to display the total of each order based on the order id. For instance I want to display the order id, customer id, order date, and then the extension price (ol_quantity * inv_price).
    I would then like a total displayed for order # 1 and then move on to order #2.
    Here is my SQL code :
    SELECT DISTINCT orders.o_id, customer.c_id, inv_price * ol_quantity
    FROM orders, customer, inventory, order_line
    GROUP BY orders.o_id, customer.c_id, inv_price, ol_quantity
    ORDER BY orders.o_id;
    When my code is run it displays the order id, customer id and inv_price * quantity (extension price) but no order total for the order number and a new group is not started when a new order number is started....they are all clumped together.
    Any help is greatly appreciated!!

    Hi,
    user12036843 wrote:
    I am working on a project and need to display the total of each order based on the order id. For instance I want to display the order id, customer id, order date, and then the extension price (ol_quantity * inv_price).
    I would then like a total displayed for order # 1 and then move on to order #2.
    Here is my SQL code :
    SELECT DISTINCT orders.o_id, customer.c_id, inv_price * ol_quantity
    FROM orders, customer, inventory, order_line
    GROUP BY orders.o_id, customer.c_id, inv_price, ol_quantity
    ORDER BY orders.o_id;
    When my code is run it displays the order id, customer id and inv_price * quantity (extension price) but no order total for the order number and a new group is not started when a new order number is started....they are all clumped together.
    Any help is greatly appreciated!!Sorry, it's unclear what you want.
    Whenever you post a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.
    Do you want the output to contain one row for each row in the table, plus an extra row for each distinct order, showing something about the order as a whole (e.g., total inv_price or average extension_price)? If so, you need GROUP BY ROLLUP or GROUP BY GROUPING SETS .
    If you want one row of output for each row of the table, but you want to include something that reflects the group as a whole (again, e.g, total inv_prive or average extension_pcie), then you can us analytic functions. (Most of the aggregate functions, such as SUM and AVG have analytic counterparts that can get the same results without collapsing the result set down to one row per group.)
    Here's an example of how to use GROUP BY GROUPING SETS.
    Way we're interested in employees' salary and commission from the scott.emp table:
    SELECT       deptno
    ,       ename
    ,       sal
    ,       comm
    FROM       scott.emp
    ORDER BY  deptno
    ,            ename
    ;Output:
    `   DEPTNO ENAME             SAL       COMM
            10 CLARK            2450
            10 KING             5000
            10 MILLER           1300
            20 ADAMS            1100
            20 FORD             3000
            20 JONES            2975
            20 SCOTT            3000
            20 SMITH             800
            30 ALLEN            1600        300
            30 BLAKE            2850
            30 JAMES             950
            30 MARTIN           1250       1400
            30 TURNER           1500          0
            30 WARD             1250        500Now say we want to add the total income (sal + comm, or just sal if there is no comm) to each row, and also to add a row for each department showing the total sal, comm and income in that department, like this:
    `   DEPTNO ENAME             SAL       COMM     INCOME
            10 CLARK            2450                  2450
            10 KING             5000                  5000
            10 MILLER           1300                  1300
            10                  8750                  8750
            20 ADAMS            1100                  1100
            20 FORD             3000                  3000
            20 JONES            2975                  2975
            20 SCOTT            3000                  3000
            20 SMITH             800                   800
            20                 10875                 10875
            30 ALLEN            1600        300       1900
            30 BLAKE            2850                  2850
            30 JAMES             950                   950
            30 MARTIN           1250       1400       2650
            30 TURNER           1500          0       1500
            30 WARD             1250        500       1750
            30                  9400       2200      11600(This relies on the fact that ename is unique.) Getting those results is pretty easy, using GROUPING SETS:
    SELECT       deptno
    ,       ename
    ,       SUM (sal)          AS sal
    ,       SUM (comm)          AS comm
    ,       SUM ( sal
               + NVL (comm, 0)
               )               AS income
    FROM       scott.emp
    GROUP BY  GROUPING SETS ( (deptno)
                             , (deptno, ename)
    ORDER BY  deptno
    ,            ename
    ;Notice that we're displaying SUM (sal) on each row. Most of the rows in the output are "groups" consisting of only one row from the table, so the SUM (sa) for that goup will be the sal for the one row in the group.
    Edited by: Frank Kulash on Nov 23, 2011 2:03 PM
    Added GROUPING SET example

  • SQL Select and Hints

    Hello,
    i have the following SQL-Statement:
    SELECT /*+ PARALLEL(mytable,16*/ COUNT(*)
    FROM mytable;
    Does the database use ALWAYS 16 cores (of course, if 16 cores are free) - even if the cbo (cost based optimizer ) "thinks" that this makes no sense? Or CAN the cbo use 16 cores with this sql-statement? Or if the cbo "thinks" the server has more cores as in the hint-stament, the cbo gives more cores.
    Many thanks
    Best regards
    Heidi

    Heidi Weber wrote:
    Hello,
    i have the following SQL-Statement:
    SELECT /*+ PARALLEL(mytable,16*/ COUNT(*)
    FROM mytable;
    Does the database use ALWAYS 16 cores (of course, if 16 cores are free) - even if the cbo (cost based optimizer ) "thinks" that this makes no sense? Or CAN the cbo use 16 cores with this sql-statement? Or if the cbo "thinks" the server has more cores as in the hint-stament, the cbo gives more cores.
    Many thanks
    Best regards
    HeidiYour query is missing a bracket from the hint. ;)
    Looking at it one way, if I were to hint to you that it's a good idea to go jump off a cliff, would you do it? Answer: You'd look to see what the possibility of surviving is and if the chances were 100% survival (and you didn't have a fear of heights) you'd do it.
    Likewise Oracle will look at a hint and if it's not going to break the query or conflict with something else that is required, it will do it, but if for some reason it can't then it won't. So if you don't have 16 cores and you're telling it to use 16, then it won't do it. There are obviously various internal rules and formula that the CBO uses when determining the best execution plan, so the hint has to be looked at in the context of the whole query. In the simple example you've given, there's no reason why it shouldn't comply with the hint.

  • Please help! Invalid node structure and invalid record count

    My MacBook Pro is about 6.5 years old. I upgraded to Snow Leopard 2 years ago and added RAM at the same time. My first problem ever occurred three days ago when my computer got super sluggish, I restarted and got the gray screen with apple and spinning wheel...no boot up. I ran disk utility from the snow leopard install disk and found "invalid node structure" and "invalid record count". After reading on here what to do...try to repair the disk and so on with no success I went out and bought Disk Warrior. Got home expecting to fix everything and Disc Warrior won't boot...I just get a file with a question mark and the disc is ejected. I tried erasing the hard drive but was only able to use the "don't erase data" option. Then I tried to reinstall Snow Leopard with no luck. Now I am stuck. Any ideas? 
    One thing to note is I am to the point of not caring about the files on the hard drive, I was a dummy and never backed them up...lesson learned!  I just want my computer back without having to spend $1000+ for a new one. Then again I am always willing to do that too as a last resort.
    PLEASE HELP!

    When you contact Alsoft, make sure you let them know that you are using Snow Leopard (10.6.8).
    Try the following in the meantime -
    Disconnect all peripherals from your computer.
    Boot from your install disc & run Repair Disk from the utility menu. To use the Install Mac OS X disc, insert the disc, and restart your computer while holding down the C key as it starts up.
    Select your language.
    Once on the desktop, select Utility in the menu bar.
    Select Disk Utility.
    Select the disk or volume in the list of disks and volumes, and then click First Aid.
    Click Repair Disk.
    Restart your computer when done.
    Repair permissions after you reach the desktop-http://support.apple.com/kb/HT2963 and restart your computer.
    Try DiskWarrarior again if it's combatible with the os system.
    YOu cannot reformat until you get your issue corrected.

Maybe you are looking for

  • Overwrite data of master data infoobject

    Hi all, We have one master data infoobject ZASRYHMA. This infoobject does not have any attrbiutes but it has two compounding fields ZSITE and 0DISTR_CHAN. Now customer has a requirement in which value of ZASRYHMA can change for a particular site and

  • Updating to Lion Question

    I got my MBP with OSX 10.6 on it, and i haven't gone through any OS changing yet. so wanted to ask do I need to delete all the data on my computer to update to 10.7? or it will go nice and easy like updates?

  • A plea for a readable Java (for each, Set Integer & subclasses )

    I like the new language features a lot, but I don't like the proposed syntax. I thought the great thing about Java was that it got us away from the awful C++ punctuation soup. Here's my proposal for a more readable syntax without adding new keywords

  • Cluster setup in remote machines using weblogic8.1??

              Hi,           How to run a clustered setup in remote machines??           This is my setup:           I have a domain called mydomain           I have three server instances Adminserver, ManagedServer1 and ManagedServer2.           I have a

  • Jbo-30003 exception when logged in users exceed 100

    hi when users connected in application exceed 100 or some times 70 following error raised: Error 500--Internal Server Error oracle.jbo.common.ampool.ApplicationPoolException: JBO-30003: The application pool (org.myapp.model.services.appModuleLocal) f