SQL query - return single unique rows

Hi
If you have an employee table where employees are listed per department, using SQL, how could you return the names of the employees listed per department on a single unique row?
Eg - select deptno, first_name from employee
deptno first_name
10 Jane
20 Jack
10 Joe
20 Jill
10 Jacinta
30 John
30 Jeffrey
10 Jackie
30 Jennifer
... etc.
the return set of the query would look like:
deptno first_name concat
10 Jane Joe Jacinta Jackie ..
20 Jack Jill ..
30 John Jeffrey Jennifer ..
Cheers

Here you go:
WITH t AS
(SELECT 10 deptno, 'Jane' first_name FROM dual UNION
SELECT 20 deptno, 'Jack' first_name FROM dual UNION
SELECT 10 deptno, 'Joe' first_name FROM dual UNION
SELECT 20 deptno, 'Jill' first_name FROM dual UNION
SELECT 10 deptno, 'Jacinta' first_name FROM dual UNION
SELECT 30 deptno, 'John' first_name FROM dual UNION
SELECT 30 deptno, 'Jeffrey' first_name FROM dual UNION
SELECT 10 deptno, 'Jackie' first_name FROM dual UNION
SELECT 30 deptno, 'Jennifer' first_name FROM dual)
SELECT   deptno,
         RTRIM(XMLAGG(XMLELEMENT(c, first_name||' ') ).EXTRACT ('//text()'), ' ') names
FROM     t
GROUP BY deptno

Similar Messages

  • Creating a directory via a jsp page sql query return

    Is it possible to create a directory based on the results of a sql query?
    i.e.
    My sql query returns application number 1234 for a building application (BC for short).
    Is it possible to create a directory /BC/1234
    It is then proposed to use an iframe to look into the directory so users can place and access scanned documents which are captured during the approval process.
    If so how?
    An example would be great.
    Jason

    Sorry hope your still around I've been away for a while. We've created a samber share to the file server where the documents are stored and mounted it within the web file directory. It works ok if there is an existing directory but if there isn't we want it to be created when the page looks for the folder. I've done this with an asp page it basically did a directory exist test first then create folder if it didn't. The problem is can't find an example of how to do the directory exist test then directory create syntax so an example of both would be great

  • SQL query returns varchar - default value type!!!

    On a field in my portal form there is a default value type of 'SQL query returns varchar', where can I put this sql to get a default value from a table?

    Hi again
    I have this code in 'additional pl/sql code' - '...before displaying the page'. But it comes up with an error when I run the form.
    declare
    prop_v varchar2(20);
    group_v varchar2(3);
    el1_v varchar2(3);
    blk varchar2(10) := 'DEFAULT';
    begin
    prop_v := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT', p_attribute_name => 'l_property_p');
    group_v := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT', p_attribute_name => 'l_group_p');
    select element_code
    into el1_v
    from eh_risk_element_detail
    where property_ref = prop_v
    and group_code = group_v
    and line_no = 1;
    p_session.set_value(p_block_name => blk, p_attribute_name => 'L_ELEMENT1_P', p_value => el1_v);
    end;
    Rich

  • SQL query returns few rows, but holds on with several Gbs of RAM memory used

    If I perform the following query:
    SELECT d.DocumentGUID, d.DocumentID
    FROM ImportDataBase.dbo.Document d
    LEFT OUTER JOIN ContentDataBase.dbo.Document d2 ON (d.DocumentGUID = d2.DocumentGUID)
    WHERE ( d2.DocumentGUID IS NULL ) -- new document in the ImportDB
    OR ( d2.DocumentGUID IS NOT NULL AND d.QueryContent <> d2.QueryContent ) -- modified document in the ImportDB
    It returns around 1000 rows and takes about 3 minutes to complete
    It also raises up the RAM memory used from 2GB to 9GBs. 
    This memory used will remain used untill I restart the server. I have no need to make use of that memory, I already copied the returned rows of that query into a note pad for example. And any other reason of SQL has to  to keep that memory stored by
    that query, I  dont want it.
    Is there a way to release that memory I really dont need my SQL server to keep, without having to restart the SQL server?
    and without topping the max memory the sql server uses, since I need my SQL server to use as much as it needs in other tasks(I dont think it needs to hold on to the above query memory used)
    Thank You very much.

    Is there a way to release that memory I really dont need my SQL server to keep, without having to restart the SQL server?
    and without topping the max memory the sql server uses, since I need my SQL server to use as much
    A query can be resource intensive even if it returns a single row. Generally it is a good idea to set SQL Server MAX memory.
    BOL: "Optimizing Server Performance Using Memory Configuration Options
    The memory manager component of Microsoft SQL Server eliminates the need for manual management of the memory available to SQL Server. When SQL Server starts, it dynamically determines how much memory to allocate based on how much memory the operating system
    and other applications are currently using. As the load on the computer and SQL Server changes, so does the memory allocated. For more information, see Memory Architecture.
    The following server configuration options can be used to configure memory usage and affect server performance:
    •min server memory
    •max server memory
    •max worker threads
    •index create memory
    •min memory per query
    The min server memory server configuration option can be used to ensure that SQL Server does not release memory below the configured minimum server memory once that threshold is reached. This configuration option can be set to a specific value based on the
    size and activity of your SQL Server. If you choose to set this value, set it to some reasonable value to ensure that the operating system does not request too much memory from SQL Server, which can affect SQL Server performance.
    The max server memory server configuration option can be used to specify the maximum amount of memory SQL Server can allocate when it starts and while it runs. This configuration option can be set to a specific value if you know there are multiple applications
    running at the same time as SQL Server and you want to guarantee that these applications have sufficient memory to run. If these other applications, such as Web or e-mail servers, request memory only as needed, then do not set the max server memory server
    configuration option, because SQL Server releases memory to them as needed. However, applications often use whatever memory is available when they start and do not request more if needed. If an application that behaves in this manner runs on the same computer
    at the same time as SQL Server, set the max server memory server configuration option to a value that guarantees that the memory required by the application is not allocated by SQL Server."
    LINK: 
    http://technet.microsoft.com/en-us/library/ms177455(v=sql.105).aspx
    Memory configuration:
    http://www.sqlusa.com/bestpractices/memory-configuration/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Exists (SQL query returns at least one row) condition with MAX on 10.2.0.4

    I just wanted to note this on the forum..
    I'm using Apex 3.0.1.00.08
    My DEV environment has just been upgraded from 10g version 10.2.0.2.0 to 10.2.0.4.0.
    I created the following process to select some values into some items on my Form page.
    select  MAX(STAT_YEAR+1)
          , pcd.pct_id
          , pcd.stat_type_id
          , pcd.stat_period_type_id
          , pcd.measurement_id
    into    :P11_STAT_YEAR
          , :P11_PCT_ID
          , :P11_STAT_TYPE_ID
          , :P11_STAT_PERIOD_TYPE_ID
          , :P11_MEASUREMENT_ID
    from  plant_commodity_data pcd
        , stat_type stt
    where pcd.STAT_TYPE_ID = stt.STAT_TYPE_ID
      and pcd.pct_id = :P0_PCT_ID
      and stt.stat_type = 'PRD'
    group by pcd.pct_id
          , pcd.stat_type_id
          , pcd.stat_period_type_id
          , pcd.measurement_id;The process should run conditionally if there was at least one row to select...
    So I copied the SQL into the Process condition, removed the "into" section and set the condition type to be "Exists (SQL query retruns at least one row) ...
    select  MAX(STAT_YEAR+1)
          , pcd.pct_id
          , pcd.stat_type_id
          , pcd.stat_period_type_id
          , pcd.measurement_id
    from  plant_commodity_data pcd
        , stat_type stt
    where pcd.STAT_TYPE_ID = stt.STAT_TYPE_ID
      and pcd.pct_id = :P0_PCT_ID
      and stt.stat_type = 'PRD'
    group by pcd.pct_id
          , pcd.stat_type_id
          , pcd.stat_period_type_id
          , pcd.measurement_id;This worked perfectly until the DEV environment was upgraded from 10g version 10.2.0.2.0 to 10.2.0.4.0.
    The condition would fire even if there were no rows returning.
    I pasted the condition code into SQL Developer connected to the DEV (10.2.0.4.0) environment and it returned no rows.
    To solve the problem, I removed the MAX.
    You can test this using this code if you have access to the two versions... select  MAX(1)
          , sysdate
          , 'Gus'
    from  dual
    where 1 = 2
    group by sysdate, 2Now I know the MAX isn't required in the condition as I'm just trying to find out if any rows exist, but it was there as I copied the code in... I was just wondering why this happened between 10.2.0.2.0 and 10.2.0.4.0?
    Gus..

    Hi Gus,
    try to execute
    select count(*) from dual where exists (select  MAX(1)
          , sysdate
          , 'Gus'
    from  dual
    where 1 = 2
    group by sysdate, 2)in SQL Developer. The above statement is generated by APEX for an "Exists (SQL query retruns at least one row)". Can't test it, because I don't have a 10.2.0.4.0 at hand.
    Does SQL Developer now show the same behavior?
    Patrick
    My APEX Blog: http://www.inside-oracle-apex.com
    The APEX Builder Plugin: http://builderplugin.oracleapex.info/
    The ApexLib Framework: http://apexlib.sourceforge.net/

  • SQL Query to convert multiple rows to a single row output

    I have the following sql query;
    SELECT B.ClientID,
    B.BillNo, B.[BillDate],
    B.CurrencyCode,
    B.BAmount
    FROM tblCompanyDetails CD
    CROSS
    APPLY (
    SELECT TOP 5 B1.ClientID,
     B1.[BillNumber],
    B1.[BillDate], B1.[CurrencyCode] AS CCY,
     B1.[BillAmount]
    FROM tblBills B1
    WHERE ROUND(B1.[BillAmount],2)<>0
    AND B1.ClientID=CD.CompanyID
    AS B
    WHERE CD.ContactId=235405
    ORDER
    BY B.ClientID,B.BillNo
    DESC
    This gives me the following row output;
    ClientID
    BillNo
    BillDate
    CurrencyCode
    BAmount
    94466
    425616
    2015-04-07
    GBP
    5000
    94466
    424517
    2015-01-15
    GBP
    6000
    94466
    424455
    2014-10-15
    GBP
    4000
    However, I would like the ouput to appear like this;
    ClientID
    BillNo1
    BillDate
    CCY
    BAmount
    BillNo2
    BillDate
    CCY
    BAmount
    BillNo3
    BillDate
    CCY
    BAmount
    94466
     425616
     2015-04-07
     GBP
     5000
     424517
     2015-01-15
     GBP
     6000
     424455
     2014-10-15
     GBP
    4000 

    I have tried to create a sample based on your question
    CREATE TABLE MyTable
    ClientID INT ,
    BillNo INT,
    BillDate DATE,
    CurrencyCode varchar(5),
    BAmount INT
    INSERT INTO MyTable
    VALUES (94466,425616,'2015-04-07','GBP',5000),
    (94466,424517,'2015-01-15','GBP',6000),
    (94466,424455,'2014-10-15','GBP',4000)
    Then I have used another table to put ranking in that, you can actually tweak your statement to include rank also
    CREATE TABLE RowTable
    ClientID INT ,
    BillNo INT,
    BillDate DATE,
    CurrencyCode varchar(5),
    BAmount INT,
    Ranking INT
    INSERT INTO RowTable
    SELECT * , ROW_NUMBER() OVER (ORDER BY ClientID) as row
    FROM MyTable
    Once your data is ready then execute below dynamic query
    DECLARE @cols AS NVARCHAR(MAX),
    @query AS NVARCHAR(MAX)
    select @cols = STUFF((SELECT ',' + QUOTENAME(col+cast(Ranking as varchar(10)))
    from RowTable
    cross apply
    select 'BillNo', 1 union all
    select 'BillDate', 2 union all
    select 'CurrencyCode', 3 union all
    select 'BAmount' , 4
    ) c (col, so)
    group by col, so, Ranking
    order by Ranking, so
    FOR XML PATH(''), TYPE
    ).value('.', 'NVARCHAR(MAX)')
    ,1,1,'')
    set @query = 'SELECT ClientId,' + @cols + '
    from
    select clientid, col+cast(Ranking as varchar(10)) col, value
    from RowTable
    cross apply
    SELECT ''BillNo'', cast(BillNo as varchar(20)) union all
    SELECT ''BillDate'', cast(BillDate as varchar(20)) union all
    SELECT ''CurrencyCode'', CurrencyCode union all
    SELECT ''BAmount'', CAST(BAmount as varchar(10))
    ) c (col, value)
    ) x
    pivot
    max(value)
    for col in (' + @cols + ')
    ) p '
    execute sp_executesql @query;
    Output: 
    Hope this will help. 

  • APEX,PDF's, BI Publisher and SQL Query returning SQL code..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title adjusted to allow people to know what I am talking about...
    Message was edited by:
    Tony Miller

    Tony,
    You can find the log as follows:
    - go to http://[yourserver]:[yourport]/em
    - logon to OC4J EM: oc4jadmin/[yourpassword]
    - click on "logs" at the bottom of the page
    - in the hgrid/tree, expand OC4J->home->Application
    xmlpserver
    - click on view log icon
    You can also observe what's going on in BI Publisher
    by going to the command prompt from where you started
    it.
    Or, as a third option, you can locate the file on
    your file system, depending on your setup, the path
    would be something similar to this:
    \oracle\product\10.2.0\bip\j2ee\home\application-deplo
    yments\xmlpserver\application.log
    With that said though, I don't expect you'll find
    much in there that would help with your particular
    problem. I suspect you either get no rows in your XML
    at runtime, due to some session state issues, or your
    XML structure does in fact not match your RTF
    template.
    I'm not quite following your problem description,
    i.e. when did you do what and are you associating
    your report layout with a report query or report
    region. So just some general notes, your query needs
    to be parseable at design-time, when exporting the
    XML, so that you get the XML file with the proper
    column names derived from your query. If you want to
    use your RTF template with a standard report region,
    you must export the XML file first using the advanced
    XML structure option. And of course the column names
    in your report query need to match the column names
    in your report region.
    Perhaps this helps you further diagnose what's going
    on, if you have additional information that could
    help, let me know. And if you could stage this on
    apex.oracle.com, I'd be happy to take a look.
    Regards,
    MarcMarc,
    Thanks for looking at this issue. Below find my remarks to your questions..
    Re: your query needs
    to be parseable at design-time, when exporting the
    XML, so that you get the XML file with the proper
    column names derived from your query.At the start of this process, the query code was a function in a package. The function was returning an SQL select statement, for a report region on a page. I took the select statement, built an application query to build a sample of the xml for BI Publisher desktop (Add-on for Word). The code was producing the usual Col01, Col02.. since at design time that is were the column names.
    When I then took the xml from this and built the rtf for loading into my APEX application.
    When testing the Application Query with this RTF report layout, I am getting PDF's. When using it with the report region sending an xml feed to BI Publisher I am getting nothing back.
    I have since taken the sql code and moved it back into the report region, and set the region to have a type of straight SQL Query. I have even tried to hard-code the parameters I was getting from the page to limit data returned.
    Is it possible to see the xml being produced by the APEX page?
    Re: Stage this on apex.oracle.com.. I would love to, but we would have HIPPA issues if I posted the data on a public website.
    Can I send you the RTF file and the xml file that the application query is creating to see if there something weird about them?
    Thank you,
    Tony Miller
    UTMB/EHN

  • SQL query Output  exceeds 65000 rows in excel

    Hi,
    I have a SQL file attached to my concurrent program. The query in the SQL file returns tab separated output that i need to email as a csv through the same SQL file.
    The issue I am facing is that the query returns about 157000 records but only 65536 are being displayed in the excel worksheet.
    How can I get all the records by accommodating them in multiple worksheets of the same excel file?
    Please help!
    I am using EBS 11i.
    Code I am using in SQL file:
    set pages 3000
    set lines 300
    set heading off
    set term off
    set feedback off
    set verify off
    set echo off
    set serverout off
    spool /tmp/TEST.csv
    select 'Header'
    from dual
    SELECT column1||CHR(9)||column2
    FROM staging_table
    spool off
    set lines 1000 pages 40 head off echo off veri off
    select 'cd /tmp; cat $XX_TOP/install/sql/disclaimer.txt > x.dat; cat '||'/tmp/TEST.csv'||' | uuencode '||'/tmp/TEST.csv'
    ||' > '||substr('/tmp/TEST.csv',1,length('/tmp/TEST.csv')-4)||'.dat >> x.dat'
    ||' ; mail -s ''' ||'&1'||''' '||'&2'||' < x.dat'
    ||' ; rm '||substr('/tmp/TEST.csv',1,length('/tmp/TEST.csv')-4)||'.dat'||' ;'
    from dual
    list
    spool /tmp/email.txt
    spool off
    host chmod 777 /tmp/email.txt
    host /tmp/email.txt
    Thanks
    Edited by: user10648285 on May 13, 2011 5:27 AM

    open a blank Excel (2007 version), go to Data tab, then from External Data click From Text, select the CSV file (That having more than 65k records), click import, then from "start import at row" select 65001 and click next button, select delimiter as Comma, click Next button and filaly finish.
    In this way you will have the data after 65k rows in excel. Now you can simply open that cvs file in excel then you will have first 65k records (remening part will be discarded).
    So now you have two excel files and you can paste it in two diff tab.
    Note - you can repeate this activity if you have more than 130000 records...

  • SQL Query updateable report with row selector. Update process.

    I have a SQL Query updateable report with the row selector(s).
    How would I identify the row selector in an update process on the page.
    I would like to update certain columns to a value of a select box on the page.
    Using the basic:
    UPDATE table_name
    SET column1=value
    WHERE some_column=some_value
    I would need to do:
    UPDATE table_name
    SET column1= :P1_select
    WHERE [row selector] = ?
    Now sure how to identify the [row selector] and/or validate it is checked.
    Thanks,
    Bob

    I don't have the apex_application.g_f01(i) referenced in the page source...In the page source you wouldn't find anything by that name
    Identify the tabular form's checkbox column in the page(firebug/chrome developer panel makes this easy)
    It should be like
    &lt;input id=&quot;...&quot; value=&quot;&quot; type=&quot;checkbox&quot; name=&quot;fXX&quot; &gt;we are interested in the name attribute , get that number (between 01 and 50)
    Replace that number in the code, for instance if it was f05 , the code would use
    apex_application.g_f05
    --i'th checked record' primary keyWhen you loop through a checkbox array, it only contains the rows which are checked and it is common practice to returns the record's primary key as the value of the checkbox(available as the the i'th array index as apex_application.g_f05(i) , where i is sequence position of the checked row) so that you can identify the record.

  • Performance of an sql query with 16 million rows

    Hello,
    I have about 16 million records in a project table, lets call it the ENCOUNTER table.
    I have an ENCOUNTER_NUMBER to be searched for which is VARCHAR2(30) and has a unique constraint on it. The results are to be ordered by ENCOUNTER_NUMBER.
    The search string that the user enters is always considered to be a contains search and so a % is prefixed and suffixed to the search string.
    I have created a functional index on UPPER(ENCOUNTER_NUMBER)
    More the number of matches to the search query, the less the time taken. If there are 100 matches or more, the query returns within a second.
    If there is only one match it takes atleast 10 seconds.
    I am not sure at this stage why there is huge difference. Our client would be happy with 5 seconds.
    Can anyone help me with this please, if at all it is possible to get the search quicker
    Any help would be greatly appreciated.
    Many thanks
    Marilyn

    You are seeing differing response times to fetch the first n rows - not all the rows. So if your search is 'less selective' then you need to search fewer rows to find the first n rows meeting your criteria.
    For example, if you have a search that 1% of your rows will match, then you probably need to scan about 10,000 rows to find the first 100 matching rows. If you specify a more selective predicate, matching 0.1% of the rows, then you will need to scan 100k rows to find your first 100 matches.
    A generic 'contains' query, such as you describe, is difficult to implement with good performance. And it is often the result of someone not giving sufficient thought to the requirements: 'Well, it's too hard to figure out how people really need to use it, so I'll ask for this and I'll be covered regardless of what people really need.'
    Can you negotiate/narrow down the requirements, such as:
    - allow leading wildcards or trailing wildcards but not both
    - allow/require other search criteria to be specified (not more double-wildcarded criteria, though)
    - allow searching specific positions of the column (for example, if positions 4-6 have some specific meaning, then allow a search on that substring)

  • SQL Query returns question marks

    I am seeing a SQL Query, executed via ADODB in VB, from a 10G client (don't know exact version) to a Sun Solaris based 9.2.0.5.0 Server return all question marks...Table queried consists of 3 columns, 2 varchar2, one long: Here query:
    SELECT SETTINGVALUE FROM EWORKFLO.CONFIG WHERE SETTINGGROUP='New test' AND SETTINGNAME='Single Page'
    The query results in 2576 question marks...(????? etc).
    Any idea what may be going on here?
    Thanks...
    Leendert

    Hello Tak,
    Thanks for replying. When this query is run from SQLPLUS we get a proper result back, that is the actual values from the SETTINGVALUE column. This is the LONG column and contains data like this:
    [Scan Section]
    DeviceTimeout=15
    Display=1
    hDCCreate=0
    Unit=0
    DialogTitle=
    IniFileName=c:\winnt\temp\kf.ini
    IniSectionName=Scan Section
    DeviceCache=1
    etc....etc....
    Depending on the settings created, the return string may vary in length.
    Leen

  • SQL Query returns values like "---" and "NA"

    Hi
              When I execute a sql query in MII it returns values like "---" and "NA" for empty Char and numeric fields respectively.
    I have checked the database and made sure that these fields does not have any value. This happens only when I run the query through MII. Can any one know how can we get rid of these values?
    Thanks in advance
    Shaji

    Shaji,
    MII sets those values as a default if it discovers null values in a query result. You can change this default behaviour in several ways.
    First, have a look at the document [Setting custom null values in XML|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70628af0-8ec4-2c10-7da2-f451e412dd8f?quicklink=index&overridelayout=true]. Then you may also use SQL functions like [NVL|http://www.techonthenet.com/oracle/functions/nvl.php] to change the value directly in the SQL query. You can also change the value inside the MII BLT to whatever you need.
    Michael

  • Calling a PL/SQL function returning Netsed Table Rows

    Hi,
    I am trying to call a Function which returns Nested Table rows (as Out Parameter) in Java .
    When I am trying to use
    pstmt.registerOutParameter(3, OracleTypes.OTHER);
    to capture the Out parameter in Java code , I get the follwoing error :
    java.sql.SQLException: Invalid column type
    I have even tried using OracleTypes.JAVA_OBJECT ,but I get the same error.
    If I use OracleTypes.JAVA_STRUCT I get
    java.sql.SQLException: Parameter Type Conflict: sqlType=2008
    error.
    Please help .
    Am I doing the right thing ?
    Thanks in advance.
    Ninad

    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/jdbc20/jdbc20.html

  • Why does Oracle SQL query returning a date field without the time component

    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!

    hokim wrote:
    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!http://edstevensdba.wordpress.com/category/nls_date_format/

  • SQL Query to Fetch 500 Rows at once

    Hi,
      Due to performance issue of the SQL query takes lot of time to execute. I tried modifying the code as mentioned below but it is not working to fetch when search is implemented. Actually data is more than 1 Million Records so it takes lot of time to query the data.
    SELECT DISTINCT
    IMV.*,
      nvl(imv.party_name,imv.bill_to_name) "Bill To Name",
      Imv.Ship_To_City "Reseller City",
      Imv.Ship_To_State "Reseller State",
      Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'COUNTRY') "Reseller Country",
      Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'THEATER') "Reseller Theater",
      Cl.City "Customer City",
      Cl.State "Customer State",
      EDB2_GLOBAL.COUNTRY_NAME_THEATER(CL.COUNTRY,'COUNTRY') "Customer Country",
      EDB2_GLOBAL.COUNTRY_NAME_THEATER(CL.COUNTRY,'THEATER') "Customer Theater"
    FROM IB_SUPPORT_CONTRACTS_MV IMV,
      customer_products cp,
      customer_locations cl
    WHERE
    UPPER(TRIM(IMV.SERIAL_NUMBER)) = UPPER(TRIM(CP.PRODUCT_SERIAL_NUMBER(+) ) )
    AND CP.LOCATION_ID                     = CL.LOCATION_ID(+)
    AND ROWNUM <= 501
    Please suggest me how to improve the performance of the query.
    Thanks
    Sudhir

    Hi,
    As mentioned already, this condition is really hurting performance:
    UPPER(TRIM(IMV.SERIAL_NUMBER)) = UPPER(TRIM(CP.PRODUCT_SERIAL_NUMBER(+) ) )
    Could you trim and capitalize the serial numbers before storing them?  Do you really need to remember exactly how the serial numbers were entered?  If you really do, then store it in one column, and store UPPER (TRIM (serial_number)) in a different column.  Starting in Oracle 11, this could be a virtual column; in any version (7 or higher), it could be maintained by a trigger.  Failing that, create a function-based index on UPPER (TRIM (serial_number)).

Maybe you are looking for