Basic sql doubt

hi all
observe the below query
SELECT RTRIM(XMLAGG(xmlelement (e,ename,',')).EXTRACT('//text()')) a
FROM EMP
group by deptno
it gives output as below
A
KING,MILLER,CLARK,
JONES,ADAMS,SMITH,FORD,SCOTT,
BLAKE,JAMES,TURNER,MARTIN,WARD,ALLEN,
CF_TYPE,CF_TYPE,CF_TYPE,
in the above output fourth row is having duplicate names
but i need to avoid duplicates and print all distinct as below
A
KING,MILLER,CLARK,
JONES,ADAMS,SMITH,FORD,SCOTT,
BLAKE,JAMES,TURNER,MARTIN,WARD,ALLEN,
CF_TYPE,Please help me on this.
am using oracle Application Express 4.0.2.00.08thanks for all in advance

Hi,
WITH data AS
     SELECT deptno, ename, DENSE_RANK() OVER (PARTITION BY deptno ORDER BY  ename) rn
     FROM   emp
     SELECT DISTINCT deptno, LTRIM(SYS_CONNECT_BY_PATH(ename,','),',') ename 
     FROM   data
     WHERE  CONNECT_BY_ISLEAF = 1
     CONNECT BY PRIOR rn + 1 = rn
     AND PRIOR deptno = deptno
     START WITH rn = 1
     ;

Similar Messages

  • ABAP SQL Doubt

    Hi ABAP Gurus,
    Please help me in solving following ABAP SQL doubt.
    In the table Zonfig there are two fields: FNAME and REQFLAG
    FNAME.....REQFLAG
    S1...........X
    S2...........X
    S3..........._
    S4...........X
    Other table T_Zconfig has one field : XNAME
    XNAME
    S1
    S3
    Now I have to select REQFLAG from Zconfig table for the values of field XNAME in T_Zconfig table.
    That is in this case for FNAME S1 and S2 in Zonfig I need to fetch REQFLAG since in XNAME in T_Zonfig we just have S1 and S2.
    Points will be surly awarded...
    Thanks.

    Hi ABAP Gurus,
    Please help me in solving following ABAP SQL doubt.
    In the table Zonfig there are two fields: FNAME and REQFLAG
    FNAME.....REQFLAG
    S1...........X
    S2...........X
    S3..........._
    S4...........X
    Other table T_Zconfig has one field : XNAME
    XNAME
    S1
    S3
    Now I have to select REQFLAG from Zconfig table for the values of field XNAME in T_Zconfig table.
    That is in this case for FNAME S1 and S3 in Zonfig I need to fetch REQFLAG since in XNAME in T_Zonfig we just have S1 and S3.
    Points will be surly awarded...
    Thanks.

  • Basic FICO doubt regarding posting expenses....

    Hi,
    I am an ABAPer. I have a basic FI doubt. We are using Project system in our company. Now for expenses, the employee enters the data in third party systems. Th third party systems then provide us with the data file which will be posted in SAP.
    The business says that if a given expense by an employee, has Project status released, then the amount for that expense should be posted to cost center otherwise the amount for that expense should be posted to the project(WBS).
    Now what does business people mean by posting expense amount to cost center or posting expense amount to Project (WBS). Where in FI can I see the option of posting amount to cost center versus posting amount to project ? Is there any transaction we can do that ?
    Regards,
    Rajesh.

    when you post to wbs element it is a cost collector which can be settled later, where as cost center is a department. When you have a project, it has on going expenese instead directly posting to a cost center , you are collecting costs in a wbs element and settling it later to cost center. you can post to the wbs element same way as cost center.

  • Basic SQL query scripts for SAP B1

    hi guys,
    do you have any documents, guides or reference links regarding basic SQL query scripts for SAP B1?
    thanks and have a nice day!
    blake p.

    Hi
    You can also check SBONotes.com.
    For sql understanding , you can search in websearch - tsql and it will pop up with informations you need.
    You can also refer to forum once you understand the basic techniques
    Hope this helps
    Bishal

  • How to test basic sql queries online(for Sql Server 2012 and up versions) ?

    Hi,
    I need to test basic sql queries using sql server without installing Sql Server on to the system.
    Do we have such readymade online help, which can solve such difficulties ?
    Please sugest some of url's.
    Thanks.

    Thanks for reply.
    I am looking specific Sql Server.
    Hi Maggy,
    I strongly recommend you install SQL Server 2012 express edit and test your T-SQL queries. We can download it from the following site:
    Microsoft® SQL Server® 2012 Express:
    http://www.microsoft.com/en-hk/download/details.aspx?id=29062
    Regards,
    Elvis Long
    TechNet Community Support

  • Basic pl/sql doubt

    Declare
    cursor curname is select * from employees where employee_id in (100,101);
    v_emp curname%rowtype;
    begin
    open curname;--this stage the query is executed and datas are available in Active set which is the area oracle allocated for this cursor
    loop
    fetch curname into v_emp;
    exit when curname%notfound;--first value is retrieved in the above statement and the cursor is pointing to second value in the active set..so this wil result no
    --bt for the next loop here cursor should nt point to anything and this should exit.. Am i ryt? becaz there are totally two values.. tis should exit witout printing..
    -- i mean.. eventhough tis query gives two values second value should not be printed becaz we have given exit before before dbms_ouput statement.. ple help
    --mainly I am getting confused about the functionalities of exit explain please.....
    dbms_output.put_line('name:'||v_emp.first_name);
    end loop;
    close curname;
    end;
    tis is confusing somebody help please?? and gimme the link where can I find docs to clarify these doubts.. explain about for loop for the same please...
    I am starter in PL/SQL please help.....
    Edited by: user12869307 on Apr 19, 2010 2:43 PM

    Hi,
    Please don't post unformatted code.
    Indent line to show the extent of BEGIN, LOOP and similar statements.
    Don't put too much on one line.
    For example:
    Declare
        cursor curname is select  *
                           from    employees
                    where   employee_id     in (100,101);
        v_emp curname%rowtype;
    begin
        open curname;     -- this stage the query is executed and
                        -- datas are available in Active set which is
                   -- the area oracle allocated for this cursor
        loop
            fetch curname into v_emp;
            exit when curname%notfound;     -- first value is retrieved in the above
                                    -- statement and the cursor is pointing to
                             -- second value in the active set..so this wil result no
                             -- bt for the next loop here cursor should nt point to
                             -- anything and this should exit Am i ryt? becaz there
                             -- are totally two values.. tis should exit witout printing wiout
                             -- doing the below print..
            dbms_output.put_line ('name:' || v_emp.first_name);
        end loop;
        close curname;
    end;
    /Type these 6 characters:
    (small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    I'm not sure I understand your comments.  It would help if you posted the contents of your table, and the output you get, and asked a question specifically about those results, such as "Why do the results include ... ?  Isn't the code supposed to ... because of ... in the data?"
    If the query returns 2 rows, then FETCH will work 2 times with %FOUND = true.  Only after the 3rd call to FETCH will %NOTFOUND become true.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • What Are the Oracle Extensions Beyond Basic SQL?

    I think I write some pretty mean queries. I've written some very tight queries with nested selects and in-line selects that take up four or five printed pages. However, all of my queries are limited to the basic clauses; select, from, where, group by, having, and order by, with a bunch of case statements and a handful of custom functions thrown in.
    I recently saw a post on the ApEx forum that made me realize there is much more you can do with a SQL statement besides select...from...where. The post included a 'with' clause and a 'level' clause.
    Where can I find a compilation of other SQL clauses/statements? I would really like to get my hands on a book as opposed to web links, but anything will be appreciated.
    Thanks very much,
    Gregory

    The best place is still SQL Reference
    Nicolas.

  • Pl/sql doubts clarification

    Hi,
    I have doubts with some of the questions given below:
    1.Identify two features of obfuscation. (Choose two.)
    A. The Import and Export utilities accept wrapped files.
    B. SQL' Plus cannot process the obfuscated source files.
    C. Only the wrap utility can obfuscate multiple programs at a time.
    D. Both the DBMS_DDL package and the Wrap utility can obfuscate multiple programs at a time.
    E. The source code is visible only through the DBA_SOURCE view and not through the USER_SOURCE or
    ALL_SOURCE View
    ANSWER: A and C(not sure)
    2.The anonymous block gives an error on execution. What Is the reason?
    A.
    The assignment in line 7 is not valid.
    B.
    The SQL does not support the Boolean data type.
    C.
    A null value cannot be applied to the bind arguments In the using clause in line 10
    D.
    The names of bind variables must be the same as the using clause bind arguments in line 10
    Answer: A or B.
    3.SCOTT executes the procedure as follows:
    SQL>SET SERVEROUTPUT ON
    SQL>EXEC read_file ('MY_DIR', FACULTYLIST.TXT')
    What is the outcome?
    A.
    It goes into an infinite loop.
    B.
    It executes successfully and displays only the list of faculty names.
    C.
    It does not execute and displays an error message because the end-of-file condition is not taken care of.
    D.
    It executes successfully and displays the list of faculty names followed by a “no data found” error message.
    Answer: D is right or not
    4.Which two tasks should be created as functions instead of as procedures? (Choose two.)
    A.
    reference host or bind variables in a PL/SQL block of code
    B.
    tasks that compute and return multiple values to the calling environment
    C.
    tasks that compute a value that must be returned to the calling environment
    D.
    tasks performed in SQL that increase data independence by processing complex data analysis within the Oracle server, rather than by retrieving the data into an application
    Answer: A and B(not sure B or C).
    Please,kindly reply to me ASAP.
    Thank you,
    karthi
    Edited by: 998492 on Apr 7, 2013 2:32 AM

    1. Thare are so many problems in this code. I will list a few.
    1. You cant specify the size of an argument in a procedure.
    2. You can call this procedure only once in a schema, coz the name of the table to  be created is static.
    3. *No need to create the table dynamically*. You can create the table at the design time and truncate/insert as required.
         Even it will not be required, I hope, to meet your requirement( A Cursor will be enough).
    4. In the EMP table join_date should be of date datatype. If it is already a date, no need of to_date in the procedure.
    5. Not using BIND Variables.
    6. Variable "v_cmd" is not declared2. Search for "string aggregation " in this forum and show us what you tried so far.

  • Basic ABAP doubts

    Hi Experts,
    got some basic doubts..hope ppl can help me tackle them..
    1. y is sapscript client-specific when smartforms are     cross-client ?
    2. why exactly are reference fields required for Currency n Quantity Fields ?
    3. In SE93, while creating a transaction for an executable program, no variant comes in F4 even wen we have created one for the program, n wen we type in the variant, it says the Transaction is inconsistent.. is it because transaction is cross-client whereas variant is not ??
    4. where is DDIC placed?? i mean is it in database or Application server ?
    5. why do we need to have a Value table ?
    Please dont copy & paste from existing sources..it wud be great if u cud explain in ur own wrds...
    all answers wud be appropriately rewarded..
    thanks.
    bikash

    thanks for the reply guys..
    Andreas,it wud ve been better if u explain ur answers.
    pawan.
    1. smartform when activated generates a function module which becomes part of DDIC. so client-independent ... ( arent transparent tables part of DDIC ??? they are client-dependent though )...
    2. bcoz when u say amounts like 1000 rupees, 1000 refers to amount and rupees refers to currency unit.
    thats ok pawan, but how does it matter if it is rupees or USD or EURO..its anyway a field with lets say 13 digits n 2 decimals..n also the field contains only 1000, not the rupees, that part anyway can be got from the currency field.....
    3. did u test in a multiple-client system?? ie, it comes in IDES over here too, i think dats because IDES doesnt have multiple client..
      Also, if it has come in a multiple client system, wat ll happen if u run that transaction in a client in which that variant is not there..it ll throw an error right??
    4. wat my doubt is that anything that is there, also the definitions has to be stored someweher right?? so isnt the database where everything including the dictionary is stored??
    awaiting ur useful responses...
    Message was edited by: Bikash  Agarwal

  • New Trial Account - Now unable to create even a BASIC SQL Database...

    Hey,
    I signed up for a 30-day trial account on Azure, and in the first 24 hours managed to successfully set up a Windows VM, and a SQL Database.
    Over several hours, I then used the Azure SQL Database Migration tools to import a large test database from an on-premises SQL Server.
    All went fine, until suddenly, during the data migration, all connections to the Azure SQL Database were lost, both from my local machine, and from the Azure VM.
    I was unable to re-establish a connection to the Azure SQL Database.
    In desperation, I deleted the Azure SQL database, and attempted to create another.
    But every attempt failed. 
    I have tried from both the old and new Azure portals, and get the message after a few seconds "Error creating SQL Database".
    I have attempted creating databases both at "Basic" and "Standard" levels, but get the same result.
    There is still 99%+ left of the credit balance that came with the trial account, so I am at a loss as to what has happened, or what to do next.
    Can anyone help?
    Thanks

    Hi,
    Thank you for reporting this issue. I need a way to identify your account or subscription to look into what's going on. Please email me your server name or subscription id to olignat at microsoft dot com.
    Thanks,
      Oleg

  • Basic Sensor Doubts

    Hi all,
    I am having some basic doubts regarding the functionality of the sensor.
    case 1
    Assume that sensor is in inline mode.Then
    1) By default "stop" atomic attacks
    2) By default "stop" attacks that span multiple packets
    3) By default block IP address or network addresses without "blocking" being configured?
    In the above case how is "stoping" an attack differnet from blocking it?
    case 2
    Assume that sensor is in promiscous mode
    1) By default "stop" atomic attacks
    2) By default "stop" attacks that span multiple packets
    3) By default block IP address or network addresses without "blocking" being configured
    Also in this case how is "stoping" an attack different from "blocking" an IP or network address?
    Thanks in advance
    MD

    Doesn't blocking actually drop all traffic from that IP for a specified period while dropping or stopping means it drops the packets as they are triggered?

  • Use of basic SQL functions in conditional display of an item

    I'm trying to use the following to conditionally display an item.
    Condition Type is set to: "Value of Item in Expression 1 = Expression 2"
    Expression 1: "sign ( instr ( :column_name, '1*' ) )"
    Expression 2: "1"
    The :column_name column contains an asterisk delimited list of numbers. I wish to hide or show an item based on whether a specific number is in the list. When I run the page, the item never shows up. For testing purposes, I am using HTP.P to display not only the entire value of :column_name, but also the resulting value from the "sign(instr(... ))" code. The results of the HTP.P debugging show that the expression does indeed return a value of 1, but the item is still not displaying.
    Any thoughts? I'm relatively new to HTML DB, so there may be some obvious thing I am missing.

    Try setting the Condition Type to "PL/SQL Expression" and use:
    sign ( instr ( :column_name, '1*' ) ) = 1
    The express must evaluate to TRUE for the item to display. See the "Conditions Available in Oracle HTML DB" section in the Oracle HTML DB User's Guide.

  • Basic SQL queries in Scott/tiger schema...

    One of my team member who is a fresher wants to learn SQL.
    Access to Scott/tiger is available.
    Can some links or queries be posted which can be tried and will be useful to learn SQL.

    Hi,
    Read the following links:
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/toc.htm
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14251/toc.htm
    Regards
    Avinash

  • Basic sql query

    Hi all, I am trying to get a report using sql, but I do not get the data out.
    Select data1, sum(data2)
    from table1
    where date1 between '01-JAN-2007' and '01-JAN-2009'
    group by data1
    I know I have data because the query runs in sql+
    I do not get any error message, the reports is just empty.
    Can someone help me to understand what I am doing wrong?
    Many thanks
    Maria

    Hi,
    I thought you were using SQL server 2005, anyways if you are firing your query against Oracle, try this.
    Select data1, sum(data2)
    from table1
    where
    to_date(to_char(date1,'YYYY-MM-DD'),'yyyy/mm/dd') between
    to_date('2007/01/01','yyyy/mm/dd') and to_date('2009/01/01','yyyy/mm/dd')
    group by data1
    >>What is the problem with dates between Crystal reports and oracle databases?
    The problem is that when you compare the dates in strings then you need to provide them in the same format the date is stored with though you get in 'DD/MM/YYYY' on select but it is not necessarily be that, Thanks.
    Hope this helps.
    Thanks
    -Azhar

  • Basic sql update statement

    here are my columns:
    SQL> desc leaguetable;
    Name Null? Type
    LEAGUETABLEID NOT NULL NUMBER(8)
    TOURID NUMBER(8)
    TEAMNAME VARCHAR2(25)
    PLAYED NUMBER(3)
    WON NUMBER(3)
    LOST NUMBER(3)
    DRAW NUMBER(3)
    FORFOR NUMBER(3)
    AGAINST NUMBER(3)
    POINTS NUMBER(3)
    POSITION NUMBER(3)
    here is my update statement...
    Update LEAGUETABLE set played = 1, won = 1, forfor = 3, against = -2, points = 3 where tourid = 10 AND teamName = dundee ;
    here is my error...
    ERROR at line 1:
    ORA-00904: invalid column name
    i dont see anything wrong with my sql statement. any ideas?

    You put us (me) on the wrong track... ORA-00904 is "ORA-00904 string: invalid identifier" not invalid column name.
    But, there is your answer: value should be like "Dundee", with quotes.
    Example:
    SQL> desc leaguetable
    Name Null? Type
    LEAGUETABLEID NOT NULL NUMBER(8)
    TOURID NUMBER(8)
    TEAMNAME VARCHAR2(25)
    PLAYED NUMBER(3)
    WON NUMBER(3)
    LOST NUMBER(3)
    DRAW NUMBER(3)
    FORFOR NUMBER(3)
    AGAINST NUMBER(3)
    POINTS NUMBER(3)
    POSITION NUMBER(3)
    SQL> Update LEAGUETABLE set played = 1, won = 1, forfor = 3, against = -2, points = 3 where tourid =
    10 AND teamName = dundee ;
    ERROR at line 1:
    ORA-00904: "DUNDEE": invalid identifier
    SQL> Update LEAGUETABLE set played = 1, won = 1, forfor = 3, against = -2, points = 3 where tourid =
    10 and teamname = 'DUNDEE';
    1 row updated.

Maybe you are looking for

  • Single Sign On and user security with IS

    We have installed Information Steward 4.1 SP1 Patch 1 with Data Services 4.1 SP1 Patch 2 on Information Platform Services 4.0 SP 5 patch 6.  The Information Steward system is installed on it's own server.  We are connecting IS to our SAP Netweaver 7.

  • Drawing an arrow on a photo

    Is it possible to draw an arrow on a photo using iPhoto? I have a picture I want to e-mail to someone, and to draw their attention to one detail. The arrow doesn't have to look great -- it could be the equivalent of taking a Sharpie to a printed-out

  • WRT300N as an Access Point

    Hello, I own a Linksys WAG200G that is connected to the internet and to 2 computers, and I recently adquired a WRT300N router. Can I use my WRT300N as an access point that receves from my WAG200G (via wirelless).

  • Description from Source system via FDMEE

    Hi Team , For Flat files if we have description in file we can take that description also from that . If it possible to bring in the Description from other Source system . For Eg if i have source system as Oracle Ebs , can i bring in the the Descript

  • Menus left behind

    I have just loaded Adobe elements 10 for Apple onto a new Mac Pro.   All works OK but when I close the program the history and layers floating menus stay behind.  Another click is requuired to get rid of them.  I do not have that problem on my Window