Query to get data (child-parent)

Hi
i want to to display as below for the below table.But how am i to quiz the database to get the values in that order..
xxx
yyy
AI
zzz
xyz
ABC
table called web-goups/
web_groups_id, web_group_desc, flag, parent_web_group_id
101 xxx
102 yyy 101
103 zzz 101
104 xyz
105 ABC 104
106 AI 102

SQL> with t as (
  2  select 101  web_groups_id,'xxx' web_group_desc  , null parent_web_group_id from dual union all
  3   select 102 ,'yyy', 101 from dual union all
  4   select  103 ,'zzz', 101  from dual union all
  5   select  104, 'xyz ',null  from dual union all
  6   select 105, 'ABC', 104  from dual union all
  7   select 106 ,'AI' ,102 from dual )
  8  select web_group_desc
  9  from t
10  start with parent_web_group_id is null
11  connect by  prior web_groups_id=parent_web_group_id
12  /
WEB_
xxx
yyy
AI
zzz
xyz
ABC
6 rows selected.
SQL>

Similar Messages

  • Single query to get data from different databases

    i need to capture certain fields from certain tables in database 1 and certain fields from certain tables in database 2 into one file using a single SQL statement.
    i tried searching on the net
    i found that dblinks can help
    but iam not sure if ill be able to create dblinks in my situation which is:
    i need to get data from oracle to be copied to mysql
    this is not a replication acitivity, but i need certain fields from one database and certain from the other
    so what iwas thinking is, if i use an sql query to get all the fields (i need around 40) from the different oracle databases and create a singlefile with one insert per select, i can then read that file into mysql
    instead of creating multiple sql queries for each table and creating separate files and eventually separate tables in mysql.
    can anyone help me here?
    or maybe suggest another approach.
    thanks

    Hi,
    I think dblink is the only option available to get data from different databases. It will work for your case too.
    CREATE DATABASE LINK db_link CONNECT TO user_name IDENTIFIED BY  password USING 'instance_name'you must have the system privilege 'create database link' to create db links. This way you can get the required data and put it in a table in oracle. But i dont know how to put this data from oracle table to Mysql.
    HTH
    Muneer

  • MI 7.1: Query to get correct child objects for a parent

    I have this problem for both PDA and Laptop apps.
    We have created a Data object with ‘Customer’ as parent and ‘Email’ and ‘addresses’ as child to it. Customer will have basic customer info like his name, nationality etc. email and address will have zero or more emails and addresses of that customer.
    In my application I have written a query to fetch all customers, display it in a table and upon selection of one customer I will fetch the customer id which is the key and will fire one more query with customer id as input which will fetch all his addresses and display it in another table.
    Now look at this scenario: I create a new customer. Then I go on and create a new address for the same customer. The address will also have foreign key customer id as zero. Now I go on and create one more new customer. Now when I select any of there customers their id is zero (since i havent syncd). Hence my second query would fetch the same newly created address for both the customers since both of them have customer id as zero. Now there is a option for adding join in query in PDA app. I added the join like ‘address.psynckey = customer.synckeyMMW’ in my second query to fetch addresses apart from filter ‘address.customerid := custid’ where custid is input parameter. In laptop also I clicked on ‘add join condition by relation’ button which added to existing condition ‘AND (address.psynckey = customer.synckeyMMW)’. Now even after this it is not working correctly i.e. only the relevant childs for a parent record should come. Plz help.

    Hi,
    well, I have a problem in understanding.... If I create an item locally on the device - it immediately has a SyncKEy - this is not empty! Furthermore when I select on the item, I have the Top item as select criteria - aswell at the create process. I need the TOP item to create a child item.
    Do you have a chance to look into any SAP standard app to get an idea how they do it? The ITEMMANAGER should handle the requested create,delete,modify,select handling for TOp to child items - I think there is the issue.
    Regards,
    Oliver

  • Sql Query for getting data between two dates

    Dear Sir,
    I have one problem, i have date stored in varchar datatype of (X) table in mysql as it was not supporting the date format of (dd/mm/yyyy) so know the problem is,
    When i going to get the data between the the two dates it is giving the un reliable answers such that
    when i am asking the query as data between 1st April to 31st December 2009 it is showing the data from the 2008 .
    is there any way to solve this problem,please help this is an urgent requirement, your replay will be helpful to me.
    With Regards
    Ramakrishna Y

    You either have a SQL problem and this is the incorrect place to ask.
    Or you have a Java problem in code we cannot see. When posting code use the code tags. Click the CODE button and paste your code between the tags that appear.

  • Query for getting data for every quarter for financial year

    Hi,
    My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
    For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.

    lakmesri wrote:
    Hi,
    My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
    For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.
    How can you get 8 quarters within a year ? I'b be concerned here.
    lakmesri wrote:
    Hi,
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.
    First, that question is really not clearly asked. Second how could it be urgent ? You even did not tell us your Oracle version, did not show any tables descr, output sample nor any effort on your side to work on.
    Nicolas.

  • Query to get date range in Week

    Hello all,
    I wanted the get the results in terms of week like, if sysdate is 26/7/2007 Then
    I have to get previous 7 weeks including the week where sysdate exists.
    Results should come in this manner
    23rd to 27th 1 week
    16 - 20th July 2007 as 2nd week like this till 7 weeks
    I have a query but it is not giving in the above manner
    So please anybody can make a query as mentioned above.
    Query:
    SELECT TO_DATE(TO_CHAR(SYSDATE,'DD-MON-YYYY')) + ( ROWNUM - 6)+(ROWNUM+2)D,TO_DATE(TO_CHAR(SYSDATE,'DD-MON-YYYY')) + ( ROWNUM - 6)+(ROWNUM+2) R FROM DUAL CONNECT BY LEVEL < 6

    What do you want?
    -- A week
    select sysdate, sysdate+7 from dual;
    --A week from monday to sunday
    select nexT_DAY(SYSDATE, 'MONDAY'), NEXT_day(sysdate-7, 'SUNDAY') FROM DUAL
    BE CAREFUL MONDAY AND SUNDAY IF YOUR DDBB IS IN ENGLISH
    select
    nexT_DAY(SYSDATE, 'MONDAY'), NEXT_day(sysdate-7, 'SUNDAY'), TO_char(sysdate,'d'),
    (sysdate -TO_char(sysdate,'d')) as firstone,
    (sysdate + 7-TO_char(sysdate,'d') )as lastone
    FROM DUAL
    Message was edited by:
    cth

  • Select query not getting data

    i am using a query in my asp.net application "select * from tablename" it is not working. the table is in relationship with two other table i removed relation but still not working. the same query is working for the other table

    i am using a query in my asp.net application "select * from tablename" it is not working. the table is in relationship with two other table i removed relation but still not working. the same query is working for the other table
    Hello,
    It is not clear why this thread moved to VB.NET forum, but it seems that your issue is mainly related to web development, you could consider posting this issue in
    https://forums.asp.net forum to get support.
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • SQL Query to get Date Range Values

    Hi,
    The database is Oracle11i.
    I am looking for a way to generate list of dates from a fixed date in the past (could be hardcoded) to current day (sysdate).
    That is, if the fixed date is 19 June 2011 and assuming that today is 24 June 2011 the SQL should be able to generate the
    following:-
    19-June-2011
    20-June-2011
    21-June-2011
    22-June-2011
    23-June-2011
    24-June-2011
    And the constraint is that I can't make any change to the database in question. I can only fire an SQL query (SELECT). No
    usage of time dimension kind of approach (time dimension is not available here) and no procedures, PL/SQL etc. Is there any way?
    Thanks

    Jaimeen Shah wrote:
    Hi,
    The database is Oracle11i.
    I am looking for a way to generate list of dates from a fixed date in the past (could be hardcoded) to current day (sysdate).
    That is, if the fixed date is 19 June 2011 and assuming that today is 24 June 2011 the SQL should be able to generate the
    following:-
    19-June-2011
    20-June-2011
    21-June-2011
    22-June-2011
    23-June-2011
    24-June-2011
    And the constraint is that I can't make any change to the database in question. I can only fire an SQL query (SELECT). No
    usage of time dimension kind of approach (time dimension is not available here) and no procedures, PL/SQL etc. Is there any way?
    Thanks
    SQL> def date_start = '13/11/2010'
    SQL> def date_end   = '22/11/2010'
    SQL> with
      2    data as (
      3      select to_date('&date_start', 'DD/MM/YYYY') date1,
      4             to_date('&date_end',   'DD/MM/YYYY') date2
      5      from dual
      6    )
      7  select to_char(date1+level-1, 'DD/MM/YYYY') the_date
      8  from data
      9  connect by level <= date2-date1+1
    10  /
    THE_DATE
    13/11/2010
    14/11/2010
    15/11/2010
    16/11/2010
    17/11/2010
    18/11/2010
    19/11/2010
    20/11/2010
    21/11/2010
    22/11/2010

  • SQL query to get dates between two dates

    Hi,
    We have one table with start date and end date...Now i need to get all dates between start date and end date...
    Table looks like below..
    Create table date_table (start_date date,end_date date);
    Data in the table will be like below:
    start_date            end_date
    01-Jan-2013       04-Jan-2013
    01-Feb-2013       03-Feb-2013
    01-May-2013        03-May-2013
    I want a result as below..
    holiday_dates
    01-Jan-2013
    02-Jan-2013
    03-Jan-2013
    04-Jan-2013
    01-Feb-2013
    02-Feb-2013
    03-Feb-2013
    01-May-2013
    02-May-2013
    03-May-2013
    Can any one helps..?

    select * from date_table;
    START_DAT END_DATE
    01-JAN-13 04-JAN-13
    01-FEB-13 07-FEB-13
    07-MAR-13 12-MAR-13
    select start_date-1+level output from
    date_table connect by level<=end_date-start_date+1
    and prior start_date=start_date and prior sys_guid() is not null
    OUTPUT
    01-JAN-13
    02-JAN-13
    03-JAN-13
    04-JAN-13
    01-FEB-13
    02-FEB-13
    03-FEB-13
    04-FEB-13
    05-FEB-13
    06-FEB-13
    07-FEB-13
    07-MAR-13
    08-MAR-13
    09-MAR-13
    10-MAR-13
    11-MAR-13
    12-MAR-13

  • Query to get data for current week+13

    Hi Friends,
    I have two tables
    BACKLOG_WEEK_AFTER_ATP (LE)
    BACKLOG_ATP_GT_CW (RE)
    ** First I have to query whats the current week and year and it should come in this format ---- 2011-WK30
    columns in table BACKLOG_WEEK_AFTER_ATP are:
    ITEM_NUMBER      QUANTITY
    1N5418                 20
    1N5614                 30
    1N5806SM               10
    1N5811                  0
    2PFF6                  60columns in table BACKLOG_ATP_GT_CW are:
    ITEM_NUMBER     QUANTITY        YEAR_WEEK
    1N5418                30        2011-WK30
    1N5418                 5        2011-WK31
    1N5614                30        2011-WK32
    1N5806SM              30        2011-WK33
    1N5811                20        2011-WK32
    3EX473K1              20        2011-WK30My report should look like
    ITEM_NUMBER    2011-WK30  2011-WK31  2011-WK32  2011-WK33  ...............till 13th week
    1N5418                10         -5         -5         -5  ...............till 13t week
    1N5614                30         30          0          0  ................till 13th week
    1N5806SM              10         10         10         20  ................till 13th week
    1N5811                 0          0         20         20  ................till 13th week
    2PFF6                 60         60         60         60  ................till 13th week
    3EX473K1              20         20         20         20  ................till 13th weekTo get this report i have these conditions to keep in mind.
    1) If item_number not present in LE table and present in RE table then repeat what it is in RE table till 13th week
    2) If item_number not present in RE table and present in LE table then repeat what it is in LE table till 13th week
    3) If item_number present in LE and also present in RE table then do subtraction for RE - LE for that particular item_number till 13th week.
    4) If item_number is there in LE table but not present in RE table for current_week+1(today week comes as 29th week) then repeat the same which is there in LE table. If item is found in RE table for (example 32th week) then subtract RE -LE for that particular item_number
    Thanks in advance.
    Regards

    Hello,
    If you don't need the PIVOT display, then this may help you :
    with le as
    (select '1N5418' item_number, 20 quantity from dual union all
    select '1N5614' item_number, 30 quantity from dual union all
    select '1N5806SM' item_number, 10 quantity from dual union all
    select '1N5811' item_number, 0 quantity from dual union all
    select '2PFF6' item_number, 60 quantity from dual ),
    re as
    (select '1N5418' item_number, 30 quantity, '2011-WK30' year_week from dual union all
    select '1N5418' item_number, 5 quantity, '2011-WK31' year_week from dual union all
    select '1N5614' item_number, 30 quantity, '2011-WK32' year_week from dual union all
    select '1N5806SM' item_number, 30 quantity, '2011-WK33' year_week from dual union all
    select '1N5811' item_number, 20 quantity, '2011-WK32' year_week from dual union all
    select '3EX473K1' item_number, 20 quantity, '2011-WK30' year_week from dual
    row_gen as (
    select item_number, calc_year_week,
           row_number() over(partition by item_number order by calc_year_week) rn
    from
        (select le.item_number from le union select item_number from re) item,
        (select to_char(level*7+sysdate,'YYYY-"WK"WW') calc_year_week from dual connect by level<=13) week)
    select item_number, calc_year_week, calc_qty
    from row_gen, le, re
    where row_gen.item_number=le.item_number(+)
    and row_gen.item_number=re.item_number(+)
    and row_gen.calc_year_week=re.year_week(+)
    model
    partition by (row_gen.item_number)
    dimension by (rn)
    measures (calc_year_week, year_week, le.quantity le_qty,re.quantity re_qty,0 calc_qty )
    rules  (
    calc_qty[1]  =
        case when re_qty[cv()] is null then le_qty[cv()]
        when le_qty[cv()] is null then re_qty[cv()]
        else  re_qty[cv()]-le_qty[cv()]
    end,     
    calc_qty[rn>1] order by rn =
        case when re_qty[cv()] is null then calc_qty[cv()-1]
        else re_qty[cv()] - calc_qty[cv()-1]
        end           )
    order by 1,2;I am not sure this is the simplest way to do it, but the results seem to match your example.
    Regards,
    Sylvie
    Edited by: Troll35 on Jul 19, 2011 3:08 PM

  • Query to get date

    Dear All,
                Can anyone plase tell me a Function Module to get the create-date and change-date of a Database table . The requirement is that I need to get the database table names which have been changed in the new version of SAP.
    Regards,
    Vijay

    What do you want?
    -- A week
    select sysdate, sysdate+7 from dual;
    --A week from monday to sunday
    select nexT_DAY(SYSDATE, 'MONDAY'), NEXT_day(sysdate-7, 'SUNDAY') FROM DUAL
    BE CAREFUL MONDAY AND SUNDAY IF YOUR DDBB IS IN ENGLISH
    select
    nexT_DAY(SYSDATE, 'MONDAY'), NEXT_day(sysdate-7, 'SUNDAY'), TO_char(sysdate,'d'),
    (sysdate -TO_char(sysdate,'d')) as firstone,
    (sysdate + 7-TO_char(sysdate,'d') )as lastone
    FROM DUAL
    Message was edited by:
    cth

  • Join query not getting data from tables

    I have total 4 tables, zemployee, zemp_comm,zemp_adress, zemp_edu1 all  of this tables are connected through emp_id , but when I write left outer join it returns all rows but emp_id is retrunign null ,  when I insert all of the entries in respective table  it show the respective emp_id, when  i left some of the entries in table it will not show  emp_id in records,
    I am using this select statment........
    Select * from   zemployee as a left outer join zemp_comm as b on b~emp_id = a~emp_id left outer join zemp_adress
    as c on c~emp_id =  a~emp_id left outer  join zemp_education1 as d on d~emp_id = a~emp_id into corresponding fields of table
    emp_itb
    where  a~emp_name = zemployee-emp_name.
    I want  to show show records with emp_id whether i put entry in all tables or missed some of the entries.
    please help me in this regard.

    Hi Amir,
                You can use Inner join . please refer below code.
    Select * from   zemployee  as a inner join zemp_comm as b on b~emp_id = a~emp_id inner join zemp_adress
    as c on c~emp_id =  a~emp_id inner  join zemp_education1 as d on d~emp_id = a~emp_id into corresponding fields of table
    emp_itb
    where  a~emp_name = zemployee-emp_name.
    Regards,
    Thangam.P

  • Abnormal, Same query get data in sql but not working on Fron-end

    Dear,
    Version :Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    We have created packed in oracle database befor two months ago & was working fine, but since morning select statment in package is not working while running via application which mentioned below and raise not data found but surprising thing is that same query is getting data when we execut on sql plus return one record.
    i don't know either it's abnormal behaviour or sth else becuase the same query run without changing any singl column in where_clause work in sql but not getting data while submition request through oracle application and raising not data found.
    --thankse
    Edited by: oracle0282 on Dec 29, 2011 2:20 AM

    Actully when i run this query in sql it return one record on the same parameter, while when we exeucte this select in pl/sql on the same parameter oracle raise no data found error.
    so i got confused the same query with same parameter retur record in sql but when we call it fron-end through packege raise 'no data found error'.
    hope you understand now.
    --thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need a sql query to get multiple dates in rows

    Hi All,
    i need a query to get dates for last 7 days and each dates should be in one row...
    but select sysdate from dual..gives one row...
    Expexcted Output
    Dates:
    01-oct-2013
    30-sep-2013
    29-sep-2013
    28-sep-2013
    27-sep-2013
    26-sep-2013

    Hi,
    Do you mean that you want all 7 dates together on 1 row?
    Here's one way:
    SELECT LISTAGG ( TO_CHAR ( SYSDATE + 1 - LEVEL
                              , 'DD-Mon-YYYY'
                    ) WITHIN GROUP (ORDER BY LEVEL)    AS txt
    FROM    dual
    CONNECT BY LEVEL <= 7
    This is an example of String Aggregation, that is, taking a column on multiple rows, and concatenating all the values (however many htere happen to be) into 1 big string column 1 row.
    Like everything else, exactly how to do it depends on your Oracle version.
    For more on String Aggregation, including differetn techniques for different versions, see http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Message was edited by: FrankKulash
    Sorry, I mis-read the question.

  • Report to get data for current_week+1 till 13th week

    Hi Friends,
    I have two tables
    BACKLOG_WEEK_AFTER_ATP (LE)
    BACKLOG_ATP_GT_CW (RE)
    ** First I have to query whats the current week and year and it should come in this format ---- 2011-WK30
    columns in table BACKLOG_WEEK_AFTER_ATP are:
    ITEM_NUMBER      QUANTITY
    1N5418                 20
    1N5614                 30
    1N5806SM               10
    1N5811                  0
    2PFF6                  60columns in table BACKLOG_ATP_GT_CW are:
    ITEM_NUMBER     QUANTITY        YEAR_WEEK
    1N5418                30        2011-WK30
    1N5418                 5        2011-WK31
    1N5614                30        2011-WK32
    1N5806SM              30        2011-WK33
    1N5811                20        2011-WK32
    3EX473K1              20        2011-WK30My report should look like
    ITEM_NUMBER    2011-WK30  2011-WK31  2011-WK32  2011-WK33  ...............till 13th week
    1N5418                10         -5         -5         -5  ...............till 13t week
    1N5614                30         30          0          0  ................till 13th week
    1N5806SM              10         10         10         20  ................till 13th week
    1N5811                 0          0         20         20  ................till 13th week
    2PFF6                 60         60         60         60  ................till 13th week
    3EX473K1              20         20         20         20  ................till 13th weekTo get this report i have these conditions to keep in mind.
    1) If item_number not present in LE table and present in RE table then repeat what it is in RE table till 13th week
    2) If item_number not present in RE table and present in LE table then repeat what it is in LE table till 13th week
    3) If item_number present in LE and also present in RE table then do subtraction for RE - LE for that particular item_number till 13th week.
    4) If item_number is there in LE table but not present in RE table for current_week+1(today week comes as 29th week) then repeat the same which is there in LE table. If item is found in RE table for (example 32th week) then subtract RE -LE for that particular item_number
    Thanks in advance.
    Regards

    User_Apex wrote:
    Hi Friends,
    I have two tables
    BACKLOG_WEEK_AFTER_ATP (LE)
    BACKLOG_ATP_GT_CW (RE)
    ** First I have to query whats the current week and year and it should come in this format ---- 2011-WK30
    columns in table BACKLOG_WEEK_AFTER_ATP are:
    ITEM_NUMBER     QUANTITY
    1N5418                     20
    1N5614                     30
    1N5806SM                 10
    1N5811                       0
    2PFF6                        60columns in table BACKLOG_ATP_GT_CW are:
    ITEM_NUMBER     QUANTITY        YEAR_WEEK
    1N5418                     30                2011-WK30
    1N5418                     5                 2011-WK31
    1N5614                     30                2011-WK32
    1N5806SM                 30                2011-WK33
    1N5811                      20                2011-WK32
    3EX473K1                   20               2011-WK30My report should look like
    ITEM_NUMBER    2011-WK30  2011-WK31  2011-WK32  2011-WK33 ------ till 13th week
    1N5418                 10             -5                -5              -5     ...............till 13t week
    1N5614                 30             30               0                0     ................till 13th week
    1N5806SM              10            10              10              20    ................till 13th week
    1N5811                   0              0               20              20   ................till 13th week
    2PFF6                     60            60              60               60  ................till 13th week
    3EX473K1                20             20              20              20  ................till 13th weekTo get this report i have these conditions to keep in mind.
    1) If item_number not present in LE table and present in RE table then repeat what it is in RE table till 13th week
    2) If item_number not present in RE table and present in LE table then repeat what it is in LE table till 13th week
    3) If item_number present in LE and also present in RE table then do subtraction for RE - LE for that particular item_number till 13th week.
    4) If item_number is there in LE table but not present in RE table for current_week+1(today week comes as 29th week) then repeat the same which is there in LE table. If item is found in RE table for (example 32th week) then subtract RE -LE for that particular item_numberNot an APEX question: use {forum:id=75} forum.
    Query to get data for current week+13

Maybe you are looking for

  • Inserting line break within label

    Hey guys, i've run into a small problem with the coding. right now im creating image viewer within a horizontal list. at first, i had each object coded inside the horizontal list but then i decided to place everything in an xml file to make changes e

  • Failed to  load javax.mail.Address class

    Hi, We are using NAS 4.0 sp 6 on solaris 8. I have noticed time and again on restarting NAS, the kjs engine is not able to load the javax.mail.Address class. This happens not every time but every now and then. What could be the reason for this ? Than

  • Canonical structure mapping

    Hi Experts, Need some inputs on mapping from MATMAS05 idoc to OAGIS XSD.Has any one worked on the similar case?If so please give me the step to step approach,very helpful for me. Is there a way to modify the OAGIS xsd with out distrubing its referenc

  • Call a servlet in a frame

    I want to call a servlet in a frame: <FRAME SRC="/servlets/My_Servlet" NAME="body" NORESIZE frameborder="YES" scrolling="YES" bordercolor="#999999"> But I don't know if there is a way to pass in some parameter? Thanks.

  • High latency/pi​ng times

    Greetings I have had DSL for a while and have had no real issues until recently My problem is that I am receiving high latency/ping times while using VPN and while playing internet games (doing each exclusive of one another of course). I am continual