SELECT DISTINCT in MySQL gives error...

Anyone help with this one - I'm sure it's easy.
I have a working bean for a jsp where the statement sent to the QUERY is >> private String "SELECT * FROM mytablename ORDER BY afieldname <<. It works fine and there's no overt problems. But I dont want to return all the >> hasNext in the resultSet rs << To see the working example of why, log in at www.klaatu2u.com and go to the "ballets" menu item.
I'm trying to modify the query string to
private String "SELECT DISTINCT afieldname FROM mytablename ORDER BY afieldname " << and it's giving me a column index out of range error 3 > 1 error. As far as I can tell this comes from the resultset class in the see here below//error i keep getting...from mysql/jdbc2/
// if (columnIndex < 1 || columnIndex > Fields.length) {
// throw new java.sql.SQLException("Column Index out of range ( " + columnIndex + " > " + Fields.length + ").", "S1002");
At any rate it is erroring on my mod'd query string. No clue as to why it wont see the column index properly. I have tried "SELECT DISTINCT afieldname FROM tablename WHERE afieldname = '*' " and it doesnt give the error, just no resultset.
I'm using NETBEANS for my compiler :-/ , and mysql connector-j. I'm doing a lot of other fun stuff with it (stringtokenizing data for SPEED!) and all works well - just the DISTINCT myfieldname is no-go.
No I'm not to smart - but could sure use help anyway. Thanx much for anyone who responds...

thanks for the incredible ZERO replies and suggestions - anyhow it's fixed .

Similar Messages

  • Select query gives error in Code inspector and extended program check

    Hi,
    I have a query .
    SELECT pernr
      FROM pa9100
      INTO TABLE t_nca_tab
      WHERE endda EQ c_date AND
      z_nca_required EQ c_yes.
    This query gives me an error in Code inspector like :
    Large table pa0001: No first field of table index in WHERE  condition
    I have one more query that gives error in extended program check
    SELECT SINGLE stell ename
          INTO (g_stell, g_name)
          FROM pa0001
          WHERE pernr EQ wa_nca_tab-pernr AND
                endda EQ c_date.
    The warning says:
    *In "SELECT SINGLE ...", the WHERE condition for the key field "SEQNR" does not
    test for equality. Therefore, the single record in question may not be unique.*
    Its too urgent.
    Please reply.
    Regards,
    Binay.

    The first field is PERNR .. so if UR not giving pernr it will fetch
    all the data from the said table and between the given dates ..
    Check if this is your requirement ...
    write the select as ...
    where r_pernr is a range ...
    SELECT pernr
    FROM pa9100
    INTO TABLE t_nca_tab
    WHERE pernr in r_pernr  <----
                 endda EQ c_date AND
                 z_nca_required EQ c_yes.
    As UR using select single it's expecting to use all the key
    fields in the where condition ...
    U can ignore this warning message

  • Ora-00600 error on select distinct when using cursors

    Hi, we are using oracle9iFS version 9.0.1.1.0. When I execute the following query in sqlPlus an ora-00600 error occurs.
    Here is the query:
    SELECT     DISTINCT ODMV_FOLDER.NAME,
         CURSOR(SELECT ODMV_DOCUMENT.NAME
    FROM     ODMV_DOCUMENT
    WHERE     ODMV_DOCUMENT.ID = ODMV_FOLDERRELATIONSHIP.RIGHTOBJECT)as Document
    FROM     ODMV_FOLDER,
              ODMV_FOLDERRELATIONSHIP
    WHERE     ODMV_FOLDER.CREATOR = 96 /*this is the user 'system'*/
    AND (ODMV_FOLDER.ID = ODMV_FOLDERRELATIONSHIP.LEFTOBJECT)
    I have no clue why is this happening. I might be doing something wrong since a similar query with a nested cursor works with the scott/tiger schema. Your help is greatly appreciated. Thank you in advance.
    Alfonso.

    I was able to reproduce this error. This looks like a bug in the RDBMS; I would suggest posting on their newsgroup or working with support to handle this problem.

  • Joining multiple tables across multiple data sources in MYSQL throws error

    Hi all,
    I have to join tables across multiples MYSQL databases
    eg :
    Table T1,T2 from DB1
    Table T3 from DB2
    Columns from T3 are aggregated ( dimensional column ).
    Hence when i query using oracle answers ( say i have columns from T1,T2 and T3 ) , OBIEE tries to a query DB1 by having NULL for columns in T3
    It uses cast(NULL as INTEGER ) for columns from T3 . But MYSQL throws an error because "cast(NULL as INTEGER )" is not supported by MYSQL.
    I tried executing the query generated by OBIEE manually , if i try giving cast(NULL as SIGNED INTEGER ) , it works.
    pasting the query for reference
    select distinct D1.c2 as c1,
    D1.c1 as c2,
    cast(NULL as INTEGER ) as c3
    from
    (select distinct T87.title_id as c1,
    T59.asin as c2
    from
    print_book_catalog T59 left outer join
    title_authority T87 On T59.asin = T87.asin
    where ( T59.asin = '0345378911' )
    ) D1
    I am not able to find any config file to set this property ( and use signed integer instead of integer ) . Even DBFeatures.INI does not have relevant information.
    Can someobody please help me solve this problem.

    Stijn,
    Thank you for the article link. That was very helpful! It seems that I had a few things off as you do need the "This source should be combined with other sources at this level." checked. In my two table source columns for DATA_SOURCE I defined a literal ('086496' and '085597' for the other) in the Column Mapping tab. I pasted the following in the Fragmentation content, checking the "This source..." box on the Content tab:
    eSIS.SANDBOX4_SCHOOLS.DATA_SOURCE = '086496'
    And pasted the following into the WHERE clause, checking "Select distinct values" on the Content tab:
    sandbox4."".OBIEE.NWOCA_SCHOOLS.SCHOOL_CODE = VALUEOF(NQ_SESSION."SCHOOL") AND sandbox4."".OBIEE.NWOCA_SCHOOLS.DATA_SOURCE = VALUEOF(NQ_SESSION."GROUP")
    This took care of my user's security, utilizing the session variables in the WHERE clause. I am now able to generate reports that only one user can access from one data source and share that same report with another user who can only see data from the other data source.
    Many thanks!!!

  • Selecting distinct combination of records

    Hi Expart ,
                   I have table fields like function ,tcode,objects,fields,from ,to ,user like that in which except user all r primary key fields but i want Number of unique Function-Tcode-Object combinations when select the data.
    i am doing like that
    SELECT COUNT( distinct  FUNCTIONID TCODE OBJECT)
    FROM /PSYNG/FUNCTTRAN
    INTO L_FUN_TCD_OB
    WHERE VRSIO =  P_VRSIN.
    but it will give an error
    plz help me to get no of this combination of records .
    Thanks in advance .
    Tsen

    hi
    u can write code like this
    SELECT distinct FUNCTIONID TCODE OBJECT
    FROM /PSYNG/FUNCTTRAN
    INTO table it_L_FUN_TCD_OB
    WHERE VRSIO = P_VRSIN.
    data: var type sy-tabix.
    describe table it_L_FUN_TCD_OB lines var.
    L_FUN_TCD_OB = var.
    refresh  it_L_FUN_TCD_OB.
    Regards
    Sajid

  • String conversion gives error when converting to date format

    Hello,
    I need to convert a character to a date format. The character string is 201053131415151 where the first eight characters represent YYYYMMDD. The string may also be null ( second value). I used the following select statement
    select distinct sysdate "Run Date",
    rcreviewdate "Review Date",
    nvl((to_char(substr(rcreviewdate,1,8))),'None') "Review Date2"
    and got the following result.
    Run Date Review Date Review Date2
    30-NOV-09 201005131415151 20100513
    30-NOV-09
    1. Why is "None" not returned for the secord valule which is null?
    2. How can the valule "20100513" be converted to DD-MON-YY ( the date format)?
    to_date(substr(rcreviewdate,1,8),'YYYYMMDD') gives the following error with the null value
    Error report:
    SQL Error: ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    01841. 00000 - "(full) year must be between -4713 and +9999, and not be 0"

    Hi,
    PANY wrote:
    1. Why is "None" not returned for the secord valule which is null?
    2. How can the valule "20100513" be converted to DD-MON-YY ( the date format)?
    to_date(substr(rcreviewdate,1,8),'YYYYMMDD') gives the following error with the null value
    Error report:
    SQL Error: ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    01841. 00000 - "(full) year must be between -4713 and +9999, and not be 0"Are you sure reviewdate is NULL, and not a string consisting only of spaces or tabs?
    TO_DATE will return NULL if its 1st argument is NULL, so it looks like reviewdate is not NULL.
    You can use LTRIM (among other functions) to remove spaces from reviewdate, if that's the problem.
    Post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data.

  • How to give error message for the screen element text field when wrong i/p

    How to give error message for the screen element text field when wrong i/p
    when wrong input given
    eg. 
    I have a text box with SBOOK-CARRID
    so when user give wrong entry in text box i.e LG
    then I should give some error stating that the the input is invalid or not available ,
    now it showing the error of standard messages,
    i want manual message to be displayed when error comes.
    Thank you,
    Regards,
    Jagrut Bharatkumar Shukla

    Hi all,
    Thank you for your valuable reply,
    but the thing is that its a screen field,
    i.e text box not a selection screen
    i created in screen layout
    with name sbook-carrid
    now i want to get error message display if wrong i/p is given
    thank you.
    Regards,
    Jagrut bharatkumar Shukla,

  • While Changing the status system gives error

    Dear Experts,
    In Solution Manger,  While changing the status from Tcode SE38 with Program CRM_SOCM_SERVICE_REPORT system gives error.
    Document 8000002519 refused for technical reasons: ERROR_FREE
    Message no. SOCM_ACTION_LOG203
    Diagnosis
    The status value cannot be changed.
    The document may no longer be modifiable as a result of its status, or it may be being edited by another user.
    System Response
    This change transaction is skipped during report processing.
    Procedure
    Analyze the corresponding document during transaction processing and perform the status change manually if necessary.
    Also if i select the status as in process, then it executes sucessfully.  Please help me in this.
    Ramesh Jaiswal
    9867936636

    Hi Ramesh,
    Pls check your SP level because till SP17 this (CRM_SERV_REPORT) Tcode is not present
    I just checked.
    So it seems this is availabe only after SP18.... we can use the above report.
    Kindly confirm once you solve your problem.
    Dirk
    Can you please tell us a document which wil tel us what technical things have been changed in this new SP18.for e.g the source for this information.
    Regards
    Prakhar

  • Serious performance problem - SELECT DISTINCT x.JDOCLASSX FROM x

    I am noticing a huge performance problem when trying to access a member that
    is lazily loaded:
    MonitorStatus previousStatus = m.getStatus();
    This causes the following query to be executed:
    SELECT DISTINCT MONITORSTATUSX.JDOCLASSX FROM MONITORSTATUSX
    This table has 3 million records and this SQL statement takes 3 minutes to
    execute! Even worse, my app heavily uses threads, so this statement is
    executed in each of the 32 threads. As a result the application stops.
    Is there any way that I can optimize this? And more importantly, can Kodo
    handle a multithreaded app like this with a huge database? I've been having
    a lot of performance problems since I've started doing stress & load
    testing, and I'm thinking Kodo isn't ready for this type of application.
    Thanks,
    Michael

    You can prevent this from happening by explicitly enumerating the valid
    persistent types in a property. See
    http://docs.solarmetric.com/manual.html#com.solarmetric.kodo.PersistentTypes
    for details.
    >
    Inconveniently, this nugget of performance info is not listed in the
    optimization guide. I'll add in an entry for it.This setting did in fact prevent the query from running which fixed the
    problem. It definitely belongs in the optimization guide.
    And more importantly, can Kodo
    handle a multithreaded app like this with a huge database? I've beenhaving
    a lot of performance problems since I've started doing stress & load
    testing, and I'm thinking Kodo isn't ready for this type of application.I'd like to find out more information about details about your issues. We
    do a decent amount of stress / load testing internally, but there are
    always use cases that we don't test. Please send me an email (I'm assuming
    that [email protected] is not really your address) and let's
    figure out some way to do an analysis of what you're seeing.This email is just for posting to usenet, to avoid spam. I'm now running my
    app through stress/load testing so I hope to discover any remaining issues
    before going into production. As of this morning the system seems to be
    performing quite well. Now the biggest performance problem for me is the
    lack of what I think is called "outer join". I know you'll have this in 3.0
    but I'm suprised you don't have this already because not having it really
    affects performance. I already had to code one query by hand with JDBC due
    to this. It was taking 15+ minutes with Kodo and with my JDBC version it
    only takes a few seconds. There are lots of anti-JDO people and performance
    issues like this really give them ammunition. Overall I just have the
    impression that Kodo hasn't been used on many really large scale projects
    with databases that have millions of records.
    Thanks for configuration fix,
    Michael

  • List/Menu (multiple selected)  insert into MySQL

    I have been building a feedback form and I am running into a
    issue that when I place a list/menu that allows multiple selections
    when I submit my form in my MySQL database it collected the
    information but only on the last multiple selection.
    For example, this is what my list/menu looks like.
    <select name="occasion" size="5" multiple="MULTIPLE"
    id="occasion">
    <option value="Spur of the moment,">Spur of the
    moment</option>
    <option value="Family dinner">Family
    dinner</option>
    <option value="Special occasion (i.e.
    birthday)">Special occasion (i.e. birthday)</option>
    <option value="Office get together">Office get
    together</option>
    <option value="Romantic dinner">Romantic
    dinner</option>
    <option value="Night out with friends">Night out with
    friends</option>
    <option value="Business meeting">Business
    meeting</option>
    <option value="Other">Other</option>
    </select>
    And my MySQL database I have it set up as...
    Field Type
    occasion mediumtext
    I do not know why I cannot have more than one selection
    inputed into my field, what must I do to correct this? Everything
    works perfectly expect the multi selected list/menu. I want to
    place all that is selected in the list/menu in that one database
    field called occasion.

    .oO(MikeL7)
    >>You should also test with isset() and is_array() if
    $_POST['occasion']
    >>is available at all and of the expected type. The
    code above will also
    >>throw a notice if $insert_string is not initialized
    before the loop.
    >
    > I use both isset and is_array in my code, When you say
    notice, you dont mean
    >a script stoppiong error?
    Nope. An E_NOTICE error won't terminate the script, but
    shouldn't happen
    nevertheless. While developing, the error_reporting directive
    should be
    set to E_ALL|E_STRICT and _all_ reported problems should be
    solved. It's
    not only better coding style, but also helps to prevent real
    errors. In
    this particular case it was just a guess, because it was only
    a part of
    the code. But using an uninitialized variable with a '.='
    operator for
    example would lead to a notice, which should be fixed.
    >>But of course this is a really bad DB design, as it
    already violates the
    >> first normal form (1NF). Just some ideas for queries
    that might come to
    >> mind, but would be really hard to do with such a
    comma-separated list:
    >
    > A better table design would be to have column for |
    list_ID | user_ID |
    >song_ID | and do a insert for each song selected.
    Yes, something like that.
    >Thanks for the input, i like escaping the variables from
    a string as they
    >stand out more in code view, is the single quote method
    faster? And which one
    >will be or is already deprecated?
    All are correct and won't be deprecated. IMHO it's more or
    less just
    personal preference. It also depends on the used editor and
    its syntax
    highlighting capabilities. For example I use Eclipse/PDT for
    all my PHP
    scripts, which can also highlight variables inside a string.
    But if the
    above is your preferred way, there's nothing really wrong
    with it.
    Just some additional thoughts:
    Personally I prefer as less escaping and concatenating as
    possible,
    because such a mixture of single quotes, double quotes, dots
    and
    sometimes even escaped quote signs (for example when printing
    HTML)
    _really_ confuses me. I like to keep my code clean and
    readable.
    Something like this:
    print "<img src=\"".$someVar."\" ...>\n";
    not only hurts my eye, it is also quite error-prone. It's
    easy to miss a
    quote or a backslash and get a parse error back, especially
    in editors
    with limited syntax highlighting (or none at all). So I would
    prefer
    print "<img src='$someVar' ...>\n";
    or even
    printf("<img src='%s' ...>\n", $someVar);
    When it comes to performance issues, of course there's a
    difference
    between the various methods. But for me they don't really
    matter. In
    practice you usually won't notice any difference between an
    echo, a
    print or a printf() call for example, as long as you don't
    call them
    a million times in a loop.
    So I always just use the method that leads to the most
    readable code.
    In many cases, especially when a lot of variables or
    expressions are
    involved, (s)printf() wins. Not for performance, but for
    readability.
    But as said - personal preference. YMMV.
    Micha

  • Can't sync songs after 14 gb, itunes gives errors!! Please help!

    Hello to everyone, I'm using an Ipod classic, 6th generations, 2009 and i am using itunes with windows 8.1. After the new update of Itunes, i couldn't sync new songs to my Ipod, Itunes shows a lot of erros like 50, 53, 13039. I read and tried a lot of solutions to solve it, i uninstall the Itunes and reinstalled the latest version, it didn't help, i restore, reboot my ipod it didn't help, i deleted my whole library, i tried different cables to plug in, i used all of my usb slots, none of them has helped me!! I'm so close to throw my Ipod out!! I need some help and advice. I could be allowed to sync aprox. 14 gb of songs, but after the remaining space comes to 130 gb (or some other equal space) it starts to give errors that i mentioned above. The only thing that i didn't give a try is trying syncing my ipod with another pc. Is there anybody to help me? What can i do? I guess the problem is with my ipod's harddisk, i hope it is not, i don't want to pay money to get it repaired! All kind of helps will be appreciated! Have a nice day!

    Thank you, but I did that. I de-selected and then re-selected but because the 13019 still won't allow the sync, all it did was completely delete everything on my Ipod!  I now have no songs on my Ipod when at least before, I had all my songs but the new 12 songs!  I'm freaking! 

  • OOTB workflow gives error when user rejects in the document in publishing a major version.

    Hi All,
    I am using OOTB workflow with little customization  with following configuration
    1. Allow content approval enabled
    2. Configure a workflow with following general settings true
    3. Start workflow on publish of Major version only is enabled
    4. workflow has following configuration enabled.
    Now, when user start publishing of major version and Starts the workflow. workflow starts without any problem.
    But as and when the user rejects the document it is rejected with Reject status with "Approval Status" as well as workflow status which is expected.(This is correct )
    But when i look at the workflow history i can see at last line there is an Error with
    An error has occurred in In [Workflow Name].
    Now when user check out and check in item again and try to publish with Major version again. it gives errors that the previous version is still running.
    I have trace a lot and also test with original OOTB workflow itself. it is behaving the same.
    As per my findings there is problem in "Completion condition of this task process" the end task process is not being executed correctly.
    I tried to end the task process with End the task process action but it is still not working.
    I need some help in this issue as users are facing problems in case of rejection. I hope some one has the solution for the same.
    Two things i have noticed are
    1. My MS office 2010 professional plus is expired as i was using trial version
    2. I have made stop inheriting tasks permission and remove all default groups as i have settings in workflow "Only allow task reception and process owner to read and edit workflow task"
    3. Earlier i had also installed "Sharepoint 2010 April 2012 updates". i had also observed that (installing Sharepoint 2010 April 2012 updates) before that if user has selected "Automatically rejects the document if any participant rejected". it ends
    with "rejected" status. At present it remains in inprogress and not stops with rejected status.
    Can any one give me a hint what should be the problem ? Is it a problem with latest Sharepoint 2010 April 2012 updates ?
    Thanks,
    S. M. MANIYAR

    I have done following testing.
    1. The server in which i have not installed sharepoint 2010 April 2012 updates the above scenario is working fine without any problem
    2. I have also observed following logs of error in server where April 2012 updates is installed.
    8/28/2012 03:51:41.33  w3wp.exe (0x0F08)                        0x0A00 SharePoint Foundation        
     Workflow Infrastructure        88xr Unexpected WinWF Internal Error, terminating workflow Id# 8bf7fef1-c92e-4b22-a16f-480425d3adc6 
    08/28/2012 03:51:41.33  w3wp.exe (0x0F08)                        0x0A00 SharePoint Foundation        
     Workflow Infrastructure        98d4 Unexpected System.InvalidOperationException:
    CompositeActivity cannot transition to 'Closed' status when there are active child context still exist for child activity.     at System.Workflow.ComponentModel.Activity.MarkClosed()     at System.Workflow.ComponentModel.ActivityExecutionContext.CloseActivity()    
    at Microsoft.Office.Workflow.Actions.OfficeTask.FinalClose(Object sender, EventArgs eventArgs)     at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)    
    at System.Workflow.Runtime.Scheduler.Run() 
    Following are last two lines of workflow history.
    S. M. MANIYAR

  • Select distinct for a date column in present. service when creating prompt

    hi all
    I am trying to create some new prompts in my answers and I have the following problem. When I try to create a new prompt on a date column ( for example Modification Date), when I try to run this report on this prompt it is displaying the same date a lot of times ( for example 2/4/11 it is being displayed 4 times).
    Is there any way i can change this, so to display distinct dates?
    Thank you and best regards

    Hi Deva
    I am trying to use this, but in the system are being saved the date + hour.
    When i try select distinct modification date from My_view, i still have the same dates because they have different hours.
    When i try select disctinct to_date(modification_date)..... I am having an error in BI.
    Please help me to solve this issue.
    Regards

  • Select Distinct (More than one column)

    Hi All,
    I have the following SQL statement written in MySQL that returns only one row per MODCODE with the associated DEPTCODE of AE:
    SELECT DISTINCT
    EL_MODULE.DEPTCODE, EL_MODULE.MODCODE, EL_MODULE.MODNAME, EL_MODULE.MODLEVEL, EL_DEPTLEVEL.DEPTLEVELHEADER
    FROM EL_DEPTLEVEL, EL_MODULE
    WHERE EL_MODULE.MODLEVEL = EL_DEPTLEVEL.LEVELCODE AND EL_MODULE.DEPTCODE='AE' ORDER BY EL_MODULE.MODLEVEL
    However when I attempt to use this in oracle it returns three rows, could somebody point out what it is I need to change to get this working correctly in oracle.
    Hope someone can help.
    Jon

    Duplicates? No way! This query returns unique comibination of
    EL_MODULE.DEPTCODE,
    EL_MODULE.MODCODE,
    EL_MODULE.MODNAME,
    EL_MODULE.MODLEVEL and
    EL_DEPTLEVEL.DEPTLEVELHEADER
    Cheers
    Sarma.

  • Select distinct bug ?

    When using ‘insert into table2 select distinct field from table1′ and table2 contains a field with a default value sys_guid(), the distinct operator does not seem to work ! This was tested on Oracle 10.2.0.4 on 64 bit linux. See the following SQL code to prove it :
    create table table1 (field1 varchar2(100));
    insert into table1 (field1) values (‘value1′);
    insert into table1 (field1) values (‘value1′);
    insert into table1 (field1) values (‘value2′);
    – distinct and to_char(sysdate) function gives the correct 2 rows (‘value1′ and ‘value2′)
    create table table2 (field1 varchar2(100), field2 raw(16) default to_char(sysdate, ‘hh’));
    insert into table2(field1) select distinct field1 from table1;
    select * from table2;
    rollback;
    drop table table2 purge;
    – distinct and sys_guid function gives 3 rows (twice ‘value1′ !!) instead of 2
    create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
    insert into table2(field1) select distinct field1 from table1;
    select * from table2;
    rollback;
    drop table table2 purge;
    – with group by : no problem
    create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
    insert into table2(field1) select field1 from table1 group by field1;
    select * from table2;
    rollback;
    drop table table2 purge;
    drop table table1 purge;

    It looks like I can reproduce (on XE 10.2.0.1), with or without using a default for sys_guid:
    SQL> select banner from v$version where rownum=1;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    1 row selected.
    SQL> create table table1 (field1 varchar2(100));
    Table created.
    SQL> insert into table1 (field1) values ('value1');
    1 row created.
    SQL> insert into table1 (field1) values ('value1');
    1 row created.
    SQL> insert into table1 (field1) values ('value2');
    1 row created.
    SQL> -- distinct and to_char(sysdate) function gives the correct 2 rows (‘value1' and ‘value2')
    SQL> create table table2 (field1 varchar2(100), field2 raw(16) default to_char(sysdate, 'hh'));
    Table created.
    SQL> insert into table2(field1) select distinct field1 from table1;
    2 rows created.
    SQL> select * from table2;
    FIELD1     FIELD2
    value1     11
    value2     11
    2 rows selected.
    SQL> drop table table2 purge;
    Table dropped.
    SQL> -- distinct and sys_guid function gives 3 rows (twice ‘value1' !!) instead of 2
    SQL> create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
    Table created.
    SQL> insert into table2(field1) select distinct field1 from table1;
    3 rows created.
    SQL> select * from table2;
    FIELD1     FIELD2
    value1     5AF743C0FD484D578E84276C875C5BC1
    value1     725ABE6066BF42E2A78406BD549D9E85
    value2     CC43E3C688AF428B885A0F4EA24482CB
    3 rows selected.
    SQL> drop table table2 purge;
    Table dropped.
    SQL> -- without using DEFAULT, here Max is right (see posts below)
    SQL> create table table2 (field1 varchar2(100), field2 raw(16));
    Table created.
    SQL> insert into table2(field1, field2) select distinct field1, sys_guid() from table1;
    3 rows created.
    SQL> select * from table2;
    FIELD1     FIELD2
    value1     7B277A2068AF468EBC06E33F6700B9E3
    value1     9644C1C8A909489F98B51531BDD282D9
    value2     8707FD2E6AB94EA7810D8D4AB19AB091
    3 rows selected.
    SQL> drop table table2 purge;
    Table dropped.
    SQL> -- with group by : no problem
    SQL> create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
    Table created.
    SQL> insert into table2(field1) select field1 from table1 group by field1;
    2 rows created.
    SQL> select * from table2;
    FIELD1     FIELD2
    value2     202A87C86EF446D8915B3C976385D68F
    value1     484625A675524FA09CC393A78411B38A
    2 rows selected.
    SQL> drop table table2 purge;
    Table dropped.
    SQL> drop table table1 purge;
    Table dropped.Edited by: hoek on Feb 18, 2010 11:29 AM

Maybe you are looking for