Order within in Groups - Urgent please

Hi,
Please let me know how can I achieve the following output.
I have following four tables,
COUNTRY_MASTER table contains SL_NO, COUNTRY_CODE, COUNTRY_NAME, .... columns.
STATE_MASTER table contains SL_NO, STATE_CODE, STATE_NAME, ... columns.
COUNTY_MASTER table contains SL_NO, COUNTY_CODE, COUNTY_NAME, ... columns.
CITY_MASTER table contains SL_NO, CITY_CODE, CITY_NAME, ... columns.
I have another mapping table,
MAPPING_TABLE table contains SL_NO, COUNTRY_SL_NO, STATE_SL_NO, COUNTY_SL_NO, CITY_SL_NO, ... columns.
I want output like this -
first column is LEVEL which contains 1 for Country, 2 for State, 3 for Country and 4 for City.
second column contains all countries, states, counties and cities (all should be in one column) ORDERED within groups for the second column.
There some other columns from other tables.
1 USA
2 MI
3 MONROE
4 MONROE
3 WAYNE
4 INKSTER
4 WAYNE
2 VA
3 HENRICO
4 RICHMOND
1 WEST INDIES
2 ...
I am working on Oracle 9i Release 2. Please help.
Thanks.

A cursor would be one way to handle this...loop through the rows or you could use decode like so:
select level, decode(level, 1, nvl(cr.country_name, 'NULL'),
                            2, nvl(st.state_name, 'NULL'),
                            3, nvl(ct.county_name, 'NULL'),
                               nvl(ci.city_name, 'NULL'))
  from country_master cr, state_master st, county_master ct, city_master ci
       ((select 1 level, t_country_sl_no, 0 t_state_sl_no, 0 t_county_sl_no, 0 t_city_sl_no
          from mapping_table
         group by country_sl_no)
        union all
        (select 2 level, t_country_sl_no, t_state_sl_no, 0 t_county_sl_no, 0 t_city_sl_no
          from mapping_table
         group by country_sl_no, state_sl_no)
        union all
        (select 3 level, t_country_sl_no, t_state_sl_no, t_county_sl_no, 0 t_city_sl_no
          from mapping_table
         group by country_sl_no, state_sl_no, county_sl_no)
        union all
        (select 4 level, t_country_sl_no, t_state_sl_no, t_county_sl_no, t_city_sl_no
          from mapping_table))
where t_country_sl_no = cr.country_sl_no
   and t_state_sl_no = st.state_sl_no (+)
   and t_county_sl_no = ct.county_sl_no (+)
   and t_city_sl_no = ci.city_sl_no (+)
order by cr.country_name, st.state_name, ct.county_name, ci.city_name;

Similar Messages

  • Process order problem in COR2 - Urgent Please

    hi i have a problem in COR2.
    After creating the process order i TECO Technically complete the same,
    and when i save the process order the system just hangs.
    When i debugged the code i found that issue is inside the functional module CO_ZV_ORDER_POST - Create/change end routine order.
    It does not do the commit work properly. this is in PRD so please help me to resolve this
    I checked for other system and the process order gets saved.
    What should i do
    please help

    just  compare the  function  module  in  both  PRD & DEV  so that  see the difference in the code level  or else  in the debug  mode  upto the  hanging  code level  ....
    i think it is because of the performance  issue  ....  so  need to  be   created the index  of the  table which  it gets  updated  .....
    becuase  as your FM is  for create/chande  .... so it  will be an  big  table  .... so see it  and   do the performace trace  and  create the  index ..
    ST05 ,SCI  , SM30    .... These are  some of the  tracscation code for   Code Insecptor , performance trace & SQL trace , Runtime Analysis..
    seee if the code is  same  in both  the system   ... then it is confirmed  as   performance  issue  ....
    if the code is  different   then it is  patch level  issue ...  tell to  basis  to check the  patch level  of that  both system  and apply it.
    reward  points  if it is usefull ...
    Girish

  • Custom list column not showing up in View Order by or Group by dropdown list

    Hi All,
    I have created a custom list with a custom column called "Description". Some items in the list do not have a description. What I wanted to do is create a view where the items with a description show first, and the items with no description are
    at the bottom of the list. I thought I could make a simple view that uses the Order by or Group by on the description column.
    The problem I am having is the description column doesn't show up in the dropdown list for either Order by or Group by within the custom view. Can someone please tell me why this happens and if there is anything I can do to rectify this problem.
    I hope you can help
    Colin

    Hi,
    I believe the "Description" field type is Multiple Lines of Text. Sorting doesn't allow in this field type. In order to do the sorting, you would require to create additional column like single line of text column (note that it supports only 255
    chars and require to truncate the data if more than 255) and update the data using event receiver or workflow. and do the sorting with that column.
    kmhsad

  • Assigning sequential numbers for every lines within a group of records

    The scenario is:
    This set of records with group number, lets say 100(group number) contains 7 lines/records. How to assign line numbers (sequential) for each line within these groups on the fly during the mapping process before inserting these set of rows in the target. I know it is easy to achieve in a procedure, but not sure how to do this in the mapping.
    please advice.
    Thanks,
    Prabha

    Use Rank function
    SQL> select empno,ename,deptno,(rank() over (partition by deptno order by empno)) seqno from emp;
    EMPNO ENAME DEPTNO SEQNO
    7782 CLARK 10 1
    7839 KING 10 2
    7934 MILLER 10 3
    7369 SMITH1 20 1
    7566 JONES 20 2
    7788 SCOTT 20 3
    7876 ADAMS 20 4
    7902 FORD 20 5
    7499 ALLEN 30 1
    7521 WARD 30 2
    7654 MARTIN 30 3
    7698 BLAKE 30 4
    7844 TURNER 30 5
    7900 JAMES 30 6
    1111 Test 40 1
    1222 test 1
    1333 2
    17 rows selected

  • Page break within a group(s)

    I have a report that uses a group that contains three parts, a details part, a blank lines part, and a totals part.
    What I am attempting to achieve, is to produce the report so that there are page breaks within this group. The page breaks should happen after each part.
    I have been able to achieve the desired look by adding a group for each part, with an additional 'blank' group to provide a page break between the Details Part and the remaining 2 parts. 
    This, however has left me with 3 issues;
    Throughout the report, there will be pages with only the heading and no details.
    There are pages that show 2 headings (one for the ending detail group and the other is for successive detail group)
    How to remove the headings for the blank lines part and totals part (which is now on their own separate pages) 
    The major pain point for me is issue #3. Anyone able to offer suggestions with the amount of information provided?

    Hello,
    Based on your description, you have three part in one group. You have add page break between each part. You have mentioned that the heading will repeat in each page. You have set the tablix repeat headers on each page, right?
    Since you have blank line part in the group, when we add page break between each part, we will get a blank line page. When we have set the heading will repeat in each page, we would also have repeat page header in blank page.
    Now, what your requirement is not get the repeat header in the blank page and total page, right? Please refer to the following steps below:
    Cancel the headers repeat in each page configuration.
    Add a total row before of the detail group. Change these text box values with headers values.
    Please refer to the screenshot below:
    If there are any misunderstanding, please feel free to let me know.
    Regards,
    Alisa Tang
    If you have any feedback on our support, please click
    here.
    Alisa Tang
    TechNet Community Support

  • Urgent please: lost all datas while sync my new iPhone. how can i retrieve my old datas? through icloud?

    urgent please: I have a new iphone 4S and while sync with itunes, it was not done using the data of my old iphone but with a new virgin iphone. how can I retrieve and sync with my old datas? through icloud? or have I lost everything? please help

    to be more precise
    I have saved all my datas of my old iphone on itunes and icloud. I got a new phone 4s that I connected to itunes in order to load it and sync with my old datas. but I don't konw how but when itunes sync my new iphone i did not take my old datas. at the end of the sync process, I got an iphone totally virgin, but none of my previous apps, neither contact neither calendar neither anything. what happened? did itunes erased all my previous datas?? i hope not but if it's the case, can I recuperate my old datas through icloud? please help because as a lot of us, all my life is in this iphone.. (contacts, photos of my 18months girl, etc etc)
    thank you very much

  • Different order of subgroups groups per configuration in order by clause

    Hello,
    I have a question regarding Order by and group by of SQL. I have three tables, Groupconfig and ItemConfig and Items.
    Group has a extra field which will specify the sorting order of the items when read out from the database.
    I have the choice of Sorting by alpa description of the item or a sorting order defined on the item table.
    But when I write some SQL to retrieve all the items in the items table and join to the item config table, to get the description of the item and the sorting number,
    then join again to the groupconfig table to get the sorting of each group.
    Problem is that when I run the query the data is not quite returned in the correct order in each group as defined in the group config for each group.
    I know there are differences with the NLS_SORT variable in Oracle but I have a feeling that this is more to do with my SQL can someone help?
    I require the overall groups to be retuned by group ID, and within each group a different ordering.
    SELECT * FROM
    SELECT
    GC.GROUPID GP_GROUPID,
    GC.DESCRIP GP_DESCRIP,
    GC.SORTING_ORDER GP_SORTINGORDER,
    IC.SORTING_ORDER IC_SORDER,
    IC.DESCR IC_DESCRIPTION,
    IC.ITEMID IC_ITEMID,
    RID.UNIT I_UNIT,
    IC.SORTING_ORDER
    FROM
    RF_ITEMDETAILS RID,
    RF_ITEMCONFIG IC,
    RF_GROUPCONFIG GC
    WHERE
    IC.ITEMID = RID.ITEMID
    AND GC.GROUPID = IC.GROUPID
    ORDER BY
    CASE WHEN GC.SORTING_TYPE = 'N' THEN IC.SORTING_ORDER END,
    CASE WHEN GC.SORTING_TYPE = 'A' THEN IC.DESCR END
    ) GP
    ORDER BY GP.GP_SORTINGORDER
    But when I run this second group is correct and ordered by Numeric sorting but the first group by the sorting number field is never correct.
    Doe this SQL look correct or does anyone know if a good performat way to do this?

    maaher cant beleive I actually asked that question. thanks for your reply.
    I have changed my SQL to build up the Orber by clause using the case statements like so....( and added Product Group table in also!)
    SELECT
    PC.PRODUCTID PC_ID,
    PC.DESCR PC_DESC,
    PC.SORTING_ORDER PC_SORT,
    GC.GROUPID GC_GROUPID,
    GC.DESCRIP GC_DESCRIP,
    GC.SORTING_ORDER GC_SORTINGORDER,
    IC.ITEMID IC_ITEMID,
    IC.DESCR IC_DESCRIPTION,
    IC.SORTING_ORDER IC_SORDER,
    RID.UNIT ID_UNIT
    FROM
    RF_ITEMDETAILS RID,
    RF_ITEMCONFIG IC,
    RF_GROUPCONFIG GC,
    RF_PRODUCTCONFIG PC
    WHERE
    -- Item Configuration
    IC.ITEMID = RID.ITEMID
    AND IC.VISIBLE = 'Y'
    -- Group Configuration
    AND GC.GROUPID = IC.GROUPID
    AND GC.VISIBLE = 'Y'
    -- Product Configuration
    AND PC.PRODUCTID = GC.PRODUCTID
    AND PC.VISIBLE = 'Y'
    -- Order by
    ORDER BY
    PC.SORTING_ORDER,
    CASE WHEN PC.SORTING_TYPE = 'N' THEN GC.SORTING_ORDER END,
    CASE WHEN PC.SORTING_TYPE = 'A' THEN GC.DESCRIP END,
    CASE WHEN GC.SORTING_TYPE = 'N' THEN IC.SORTING_ORDER END,
    CASE WHEN GC.SORTING_TYPE = 'A' THEN IC.DESCR END

  • Issue services with different Internal Orders within a Plant from one PO?

    Hiii... Please advice me of issuing services through one purchase order (one vendor comes and do the service to different machines of different internal orders in a plant) to different  internal orders within a plant.
    Thanks
    Manoj

    what is the problem?  you can have Multiple Line Items in a PO  (one for each internal Order).
    And within one Line item you can add multiple service lines.

  • How to define & read Standard Text in SAPScript? Urgent Please

    Hi Experts,
    How to define & read Standard Text in SAPScript? Urgent Please..
    Thanks in advance
    good answer will points gud marks.
    sekhar

    Hi
    U can't define a standard text in a SAPScript, you call call it only by statament INCLUDE
    /: INCLUDE <ST TEXT NAME> OBJECT TEXT ID ST LANGUAGE <LANGUAGE>
    U can define it by trx SO10.
    If you need to know the text without to print it, you need to use a routine where u can use the fm READ_TEXT in order to find out the text.
    Max
    Message was edited by:
            max bianchi

  • xsd:all within xsd:group

    I'd like to have <xsd:all> within <xsd:group>.
    I.e. I want to achieve the following xml structures:
    <top><A1/></top>  or <top><A2/></top>  or  <top><A1/><A2/></top>
    or
    <top><B1/></top>  or <top><B2/></top>  or  <top><B1/><B2/></top>
    or
    <top/>
    but not
    <top><A1/><B2/></top>
    and not
    <top><A2/><B1/></top>i.e. either elements of one group or the other, but no mixing of elements of the two groups.
    Below is an extract of the schema that I am trying to apply.
    I get the following error when validating:
    "An 'all' model group must appear in a particle with {min occurs} = {max occurs} = 1, and that particle must be part of a pair which constitutes the {content type} of a complex type definition."
        <xsd:element name="top">
            <xsd:complexType>
               <xsd:choice>
                    <xsd:group ref="groupA" minOccurs="0" maxOccurs="1"/>
                    <xsd:group ref="groupB" minOccurs="0" maxOccurs="1"/>
               </xsd:choice>
            </xsd:complexType>
         </xsd:>
             <xsd:group name="groupA">
                  <xsd:all>
                         <xsd: ref="A1" minOccurs="0" maxOccurs="1"/>
                      <xsd: ref="A2" minOccurs="0" maxOccurs="1"/>
                 </xsd:all>
             </xsd:group>
             <xsd:group name="groupB">
                  <xsd:all>
                         <xsd: ref="B1" minOccurs="0" maxOccurs="1"/>
                      <xsd: ref="B2" minOccurs="0" maxOccurs="1"/>
                  </xsd:all>
             </xsd:group>...
    Unfortunately, due to existing data structures, I cannot replace the "group" by "element".
    Thanks for any suggestions!

    In your query order the results exactly how you want them
    grouped
    <cfquery ...>
    SELECT .... FROM ....
    ORDER BY make, model, derivative
    </cfquery>
    Then structure your cfoutput "groups" in the same order

  • Urgent please _ pre query

    Dear Experts,
    I have a query based on a Multiprovider with 2 cubes (inventory cube and sales order cube). I need extra information of material like material size, season and colour. So I have been advised to include an Ods/DSO in order to get this information as it is not available in the above cubes an to write a pre query for size, season, colour . I never done this before.
    Could you please guide me, urgent please? Do I need to add ods as I added the cubes before to Multiprovider and identify chars and keyfigures and then activate?
    How should I write pre query? How can I link the query I have with the pre query? Please help me
    Thanks,
    Riya

    Actually the fastest and most efficient way of doing will be adding the requested fields in the cube and load the data from DSO to cube, if the DSO is feeding data to the cube. If you don't want to go that route, then you need to include the DSO in your multiprovider and identify the fields you need, since all the cube fields are already in the DSO, then there is no need to keep the cube in the multiprovider. Now you will have one dso and one cube in the multiprovider and in identification you specify all the fields as it is in the cube you had removed.
    Hope I am clear.
    thanks.
    Wond

  • Unable to view HFM System Messages - Very Very Urgent Please.............

    I am having issues with seeing Users on system or system messages in release HFM 11.1.2.1 I get a message that *"You do not have the proper access rights to perform this task."* and I ensured that in the configuration the creator group and administrator group are set up as administrators. I have not been able to find anything that I can change security wise.
    The details of the error are below:
    *" System Messages "*
    You do not have the proper access rights to perform this task.+
    Show Details:
    Error Reference Number: {5F81E0EB-52C5-4C96-8F5A-DD9ECBAE4233}
    Num: 0x8004021d;Type: 0;DTime: 5/9/2011 8:32:22 AM;Svr: GITSHYPT01;File: CHsxServer.cpp;Line: 2457;Ver: 11.1.2.1.000.3082;
    Num: 0x8004021d;Type: 0;DTime: 5/9/2011 8:32:22 AM;Svr: GITSHYPT01;File: CHsxClient.cpp;Line: 4175;Ver: 11.1.2.1.000.3082;
    Num: 0x8004021d;Type: 0;DTime: 5/9/2011 8:32:22 AM;Svr: GITSHYPT01;File: CHFMwManageApplications.cpp;Line: 1060;Ver: 11.1.2.1.000.3082;
    *" Users on System "*
    You do not have the proper access rights to perform this task._
    Show Details:
    Error Reference Number: {1B34A605-F996-4CB9-8D7D-30C0A467170F}
    Num: 0x8004021d;Type: 0;DTime: 5/9/2011 8:33:36 AM;Svr: GITSHYPT01;File: CHsxClient.cpp;Line: 3857;Ver: 11.1.2.1.000.3082;
    Num: 0x8004021d;Type: 0;DTime: 5/9/2011 8:33:36 AM;Svr: GITSHYPT01;File: CHFMwManageApplications.cpp;Line: 1891;Ver: 11.1.2.1.000.3082;
    can anyone please assist....?
    Regards,
    Shan...

    I believe your user ID is not contained within the group set up in the HFM configuration's "application administrator". This group is independent of the role "administrator" since it is set at the server level, not application level. The same group controls access to the enable/disable connnections, and logout users feature.
    --Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • This message keeps coming up when I log in to my email ---In order to use Yahoo Mail, please turn Private Browsing off. Please go to Settings » Safari » Private Browsing, and turn it off

    this message keeps coming up each time we try to log in to our email. In order to use Yahoo Mail, please turn Private Browsing off. Please go to Settings » Safari » Private Browsing, and turn it off"
    I have gone to settings but you cannot turn off the private browsing anywhere
    can someone help,us out?
    thanks

    You turn private browsing off on the Safari page. Tap the + sign in the upper right corner, then tap private in the lower left corner. You know you're in private when the top of the screen is dark.

  • How to - correct episode order within the Remote App

    Recently I found that when i was using the Remote App to control my iTunes Library, all my TV Show episodes where in alphabetical order instead of episode number order.
    after searching on how to solve this and speaking with Apple Support (who couldn't figure out why this was happening) i couldn't find the answer and noticed that many people were having this same issue and were in the same boat as me.
    i managed to solve the issue and wanted to share. sorry if i have posted this in the wrong area, first time giving advise on here.
    ill run through this using The Walking Dead - Season 1 as an example, but this can obviously be done with any TV Show.
    Even with the correct episode numbers, iTunes displays the episode in the correct order -
    but in alphabetical order within your library on the remote app -
    in iTunes - highlight all episodes and get info
         2. under the Options Tab, change the Media Kind to Music Video and click OK at the bottom
         3. Then head over to where you Music Videos are stored
         4. select each of the episodes, get info
         5. under the Details Tab, you will now have more options to select
         6. scroll to the bottom of the Details Tab, and within the Album Artist section, type in "The Walking Dead"
         7. in the Disc Number section, you want to add which season of how many seasons there are. example - I have 4 seasons of The Walking Dead within my library, and as this is season 1, i will enter 1 of 4
         8. next, in the Track section, you want to add which episode of how may episodes in that season. example - this is episode 1 of 6 in the season
         9. next go into the Options Tab, and change the Media Kind back to TV Show
         10. click OK at the bottom
         11. once you have done this for each episode, head back into your TV Shows
         12. when you now get info for each of the episodes, the Album Artist, Disc Number and Track sections should be at the bottom of the Details Tab (if they were not there before)
         13. if this has been done correctly - all episodes should be correctly listed within the remote app by episode order
    Hopefully this has helped somebody out there!

    Gotcha - came up with a workaround... since the photos were living in the Photo Library packaged itself, and not simply in another regular folder, I right clicked on the library and said show packaged content, then search for what folders the files lived in, then copied the files out of the packaged library into a folder. Then I was able to give the Photos Library access to the new folder with the files.
    With all my files now references, I enabled iCloud Photo Library and am uploading now.
    Hopefully my new local Photo Library will be smart enough to optimize local images and shrink to give me more space.
    Thanks.

  • How to delete a path item from within a group item?

    I am generating and downloading QR codes in vector format (.eps).  I use VB scripting to place each QR code into an Illustrator document for later laser etching as a batch.  Each QR code is comprised of a bunch of small, individual filled squares all enclosed in a single large transparent square.  Here's a sample of one of the QR codes: http://laserfolly.com/2753.eps  When etching, the laser control software interprets the outside bounding square in such a way that it confuses its "inside out" algorithm used to determine whether a given path item should be etched, i.e., is it "filled".  This causes the some of the individual squares to be interpreted as not filled... even though they are.  If I delete the outer bounding square path item then all is well.  But there are hundreds of these codes in every batch... so it is time prohibitive to delete those outer squares by hand.  Here's my ask: does anyone know how to use Illustrator scripting (I'm using VB) to identify that outer square and delete it at the time that it's placed in the batch document?
    Thanks in advance for any help you can give.
    Bob

    Thanks, Mark.  That makes sense.  However, when I search all the paths in the document there are none that have a true clipping property.  My suspicion is that the bounding square is just that, a square drawn by the qr code api as a frame around the code.  You got me thinking though.  I figured out that I can identify the relevant path simply by it's dimensions and then delete it.  So here's the new sticking point: I don't think the Illustrator object model allows for interrogating path items within a group, i.e., you have to iterate through all the pathitems in the document.  Ideailly, I'd like to be able to look at only the paths within the QR code, which I add to the document as a placed item... which Illustrator treats as a group.  This document has tens of thousands of paths and so looping through all of the them to find the 50 QR codes would be super inefficient.  What do you think?  Is there a way to iterate through just the paths in a placeditem/group?
    RE VB vs. JS, I can write in both but there are a lot of reasons I'm using VB on this project.  The main reasons are that the customer is using Excel for data internally and Excel VBA is a really strong VBA object model.  I've also written more than 500,000 lines of the stuff in my career so I'm pretty comfortable solving complex problems with it.  Also, the IDE and the run-time debugging engine is oh so great for rooting out the nasties.  :-)

Maybe you are looking for