Definition of ethnicity to group a rec per person based on several conditions

Hello

The final results will be used in a report and the table. A new category for ethnicity has been added to the database.
For this reason, the field that we use to report is no longer available. I've implemented a query
identify a record per person for ethnicity codes. The rules are if the person has a record ID as
Hispanic who use little matter that they have more than one record. If the person is Hispanic,
Then identify which category they are. If they have only a record (or multiple records in the same category),
Code for the main category. If they have more than one record in all categories (except Hispanic), then count
them as multi-ethnic.

Because the table is large and is joined with other tables for the various reports, I would like to know
If there is a way more efficient and parallel to write the sql statement. In addition, for the future, they
intend to request a report that will decompose the multiethnic in different categories to display a chart.
I thought that I would need pivot 'horizontally', or could happen "vertically," the way that the
underlying table is.

In the sample data:
1st person has two records Hispanic and European; count under "Hispanic."
2nd person has two white records and Western Europe; count as 'White '.
3rd person has two records Indian and African; count under "multiethnic".
4th person has a record of the Sioux; count under "American Indian or Alaska Native".


Here is a table of sample data:
CREATE TABLE ETHTEK
(
  ID             VARCHAR2(5 CHAR),
  ETHCODE        VARCHAR2(1 CHAR),
  ETHGROUP_CODE  VARCHAR2(3 CHAR),
  ETHGROUP       VARCHAR2(30 CHAR)
);

INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11111', '5' ,'SEU', 'Southern European');
INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11111', 'H', 'SAM', 'South American');
INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11121', '5', 'WEU', 'Western European');
INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11121', '5', '5', 'White');
INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11122', '3', 'AF', 'African');
INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11122', '2', 'IND', 'Indian');
INSERT INTO ETHTEK
(ID, ETHCODE, ETHGROUP_CODE, ETHGROUP)
Values
('11159', '1', 'SIO', 'SIOUX');
Note: for do not need to create another table, I've hardcoded the translation of the description in the box instructions
in the following query. The actual query uses a lookup table.

Here's the sql code: (for some reason, in my preview, the upper/lower that the symbols are not, so put a comment on the lines that should be not equal in case they don't show up when posting)
WITH e AS                                                       --Ethnicity
        (SELECT DISTINCT id,
                         ethcode, 
                         ethgroup_code
                         ethgroup
                    FROM ethtek
        ),
        h AS                                                        --Hispanic
        (SELECT id, ethcode
           FROM e
          WHERE ethcode = 'H'),
        nhm AS                                  --Non Hispanic or Multi Ethnic
        (SELECT DISTINCT id, ethcode
                    FROM e
                   WHERE ethcode <> 'H'),             -- Not Equal 'H'
        nh AS                                                   --Non Hispanic
        (SELECT id,
                CASE
                   WHEN COUNT (*) OVER (PARTITION BY id) >
                                                             1
                      THEN 'M'
                   ELSE ethcode
                END AS ethcode
           FROM nhm
          WHERE ethcode <> 'H')                     -- Not Equal 'H'
   SELECT id, ethcode,
          CASE
             WHEN ethcode = 'H'
                THEN 'Hispanic or Latino'
             WHEN ethcode = '5'
                THEN 'White'
             WHEN ethcode = 'M'
                THEN 'Multi-Ethnic'
             WHEN ethcode = '1'
                THEN 'American Indian or Alaskan Native'
             ELSE ethcode
          END AS ethnic_desc,
          CASE
             WHEN ethcode = 'H'
                THEN '4'
             WHEN ethcode = '4'
                THEN '5'
             WHEN ethcode = '5'
                THEN '6'
             ELSE ethcode
          END AS old_ethnicity_code
     FROM (SELECT DISTINCT h.*
                      FROM h
           UNION
           SELECT DISTINCT nh.*
                      FROM nh LEFT OUTER JOIN h ON nh.id =
                                                                  h.id
                     WHERE h.id IS NULL) eth;
What is the result of the query:
Row#     ID     ETHCODE     ETHNIC_DESC     OLD_ETHNICITY_CODE
1     11111     H     Hispanic or Latino               4
2     11121     5     White                         6
3     11122     M     Multi-Ethnic                    M
4     11159     1     American Indian or Alaskan Native     1
Thus, on 7 disks, we only have 4 people once.

This is the result of summary query (not included):
     Group               Total
American Indian/Alaskan Native     1
Hispanic               1
White                    1
Multi-Ethnic               1
Total                    4

Hello

Thanks for posting the CREATE TABLE and INSERT.
The main reason for this is to allow people who want to help you recreate the problem and test their ideas. If you post statements that don't work, it defeats the purpose.
Please check all the code before you post. Each of the INSERT statements has a lack of parentheses or quotation (usually two).

If you have a parent-child relationship within the gorrace; some lines are parents of other lines, and you want the children to inherit traits from their parents.
What you posted is the usual way to the relational database for handling that: a self-join. I don't see any obvious ways to make the self-join more quickly.
You can avoid the self-join in your query if you are willing (and able) to denormalize the table and copy the traits inherited from their parents to their children. This looks like the kind of table that won't change very often, in order to maintain the standard table shouldn't be a big project. However, if the table has only 56 lines, so whatever you do with it, maybe not a great impact on the overall performance of the query.

If you want to improve performance, a more scientifically to go about this is to know what that bottlenecks in the existing query and remedy.
See these discussions on how to report a tuning issue:
When your query takes too long...
HOW to: Validate a query of SQL statement tuning - model showing
Then start a new thread, setting just about the request.

Tags: Database

Similar Questions

  • BlackBerry Q10 sms messages collapsed per person per day after that OS updated today

    After Update OS today using exit #10.1.0.4181 all my text messages have been merged per person per day.

    I can't open / read these discussions more except the last answer. Is there a way to get back to the way it was before? (all cats are readable)

    http://supportforums.BlackBerry.com/T5/BlackBerry-Q10/unable-to-send-or-receive-text-messages-after-...

  • One record per person, either the min year or year max

    Asked to show one record per person according to the following criteria: the number of years between the startyear and the courseyear is less than 4 use of the first year of course if if the number of years between the startyear and the courseyear is greater than 4 use the last (most recent) courseyear. The other problem with the data over time, the courseno has changed, but is still considered as the same course. Here are examples of data (with declaration) and the SQL code that I started to build.
    with firstlast as
    (
    select '12345' as id, 2005 as startyear, 2006 as courseyear, 'SCI221' as courseno from dual union
    select '12345' as id, 2005 as startyear, 2007 as courseyear, 'SCI221' as courseno from dual union
    select '23456' as id, 2008 as startyear, 2009 as courseyear, 'SCI221' as courseno from dual union
    select '23456' as id, 2008 as startyear, 2013 as courseyear, 'SCI226' as courseno from dual union
    select '34567' as id, 2010 as startyear, 2011 as courseyear, 'SCI221' as courseno from dual union
    select '34567' as id, 2010 as startyear, 2012 as courseyear, 'SCI221' as courseno from dual
    )
    select id, startyear, courseyear, 
    min(courseyear) over (partition by id) as minterm, max(courseyear) over (partition by id) as maxterm,
             max(courseyear) over (partition by id) - courseyear   as lagterm,
             CASE WHEN max(courseyear) over (partition by id) - (courseyear) > 2 THEN 3
                      ELSE 0
             END  as lagtermno,
    courseno
     from firstlast         
    This is the expected result.
    ID      STARTYEAR     COURSEYEAR     COURSENO
    12345    2005             2006             SCI221
    23456    2008          2013              SCI226
    34567    2010             2011              SCI221
    -----------------------------------------------------------------------------
    BANNER
    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE Production 11.2.0.2.0
    AMT for Solaris: 11.2.0.2.0 - Production Version
    NLSRTL Version 11.2.0.2.0 - Production

    Hello

    user1069723 wrote:
    ... For cases where there is more than one line per person:

    If the difference between the year of course and the start year is 3 or less choose all of the line which was the first year of classes.

    If the difference between the year of course and the start year is greater than 3, then select the entire line that is the last year of course.

    Oh, you want the first or last line.

    This is an example of a Query of Top - N . Here's a way to do it:

    WITH     got_analytics     AS
    (
         SELECT     f.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          courseyear
                           )                      AS a_num
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          courseyear     DESC
                           )                      AS d_num
         ,     MAX (courseyear) OVER (PARTITION BY id)
               - MIN (startyear)      OVER (PARTITION BY id)     AS year_dif
         FROM  firstlast  f
    )
    SELECT       id, startyear, courseyear, courseno
    FROM       got_analytics
    WHERE       1 = CASE
                   WHEN  year_dif > 3
                THEN  d_num
                ELSE     a_num
               END
    ORDER BY  id
    ;
    

    The typical top - N query is to calculate ROW_NUMBER (in ascending or descending) in a subquery and then by using the WHERE clause of the main query to get only the rows where this number is<=>
    This top - N query is somewhat different, because if we are ascending to descending order may vary the partition in the partition. In the above query, we calculate the ROW_NUMBER in both directions and then, in the main query, decide whether we will use the bottom line number or decreasing the number.

  • Creating native MSI bundle which is "per user" - based (no 'system' - based)

    I'm collecting all the information to create a native MSI package which 'by user' is based - but failed.

    This means:
    (.) The MSI should install to the local directory of the user
    (.) There should be no admin permission required

    When you use the default < fx: deploy... nativebundle = 'msi'... > element - ANT-, the MSI is created "system-wide" basis, installation in ' / Prorgram Files "and asking the admin permission.

    There is no concrete indication in the Oracle documentation (http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm) how to create "per user" basis of MSI files. Maybe, someone already did it and could tell the imprortant steps...

    Thank you!

    PS: I know - using the .exe-company with Inno Setup will create "by user" installers by default, but I don't want to use if possible .exe

    Try

    Although the name of the parameter gives no indication this is system vs by user :)

    I checked that code bundler MSI and it should honour it.

    Let me know if it works (I don't have the time to try it myself today and go on vacation for a week so won't be able to check until I'm back).

    Mark

  • How can I configure the message undeliverable in the e-mail to a specif per person email address

    I get hostile emails to a specific e-mail address.  It was agreed through mediation of the Court that that person does not contact me in a form in any way.  The sender is trying to make me respond to his emails in relplying return.  I refuse to do.  I want to put in place a message not delivered to return to her if she thinks that this (* address email is removed from the privacy *) is no longer my email address.  I was on the phone to 141 minutes last night to my ISP who have tried everything , including the implementation of a Developer tab.  She was really trying hard and we really loved ones however something if he stopped to go through but we / she couldn't get out. She suggested that speak to you guys.  I also want to note that when I created this account to get here, microsoft email, I chose, which is the email in question and also cannot be changed would not send and receive your confirmation email.  I hope that this doesn't have anything to do with what we were doing yesterday evening. I tried to return a confirmation email to the address majestique a few times, but it didn't work.  I used a different address.  Please help me.  I would appreciate your help and peace of mind, I'll get to block her emails.  I do not just want to 'block sender' I want her to stop sending emails.

    Thank you
    Nicki

    You try to deceive you want to keep the same email address and hope to deceive it no longer works.  I seriously doubt that the approach will work.  Finally it is (early or), and it is difficult to adopt without blocking mail you want to receive.

    The absolute best thing you can do is to save all messages documentation for the Court, but ignore completely, even where the non-reading and their openness.  You are being harassed by some sort of response and the best you can do is nothing.

    It is just my opinion, but reacts in any way to any messages, for me, is just what she wants.  You stop him from doing, just so ignore, or record messages and bring them to court and him.

    see you soon,

    Steve

  • Date range per week based on input parameters

    Afternoon people - I need to produce a report that will appear in coming weeks.

    There are two input parameters: P_FROM_DATE and P_TO_DATE

    I need to find the beaches of dates in weeks starting THURSDAY and ending WEDNESDAY. For example, if my P_FROM_DATE is August 1, 2012 and P_TO_DATE 11-SEP-2012, I need to show the weeks following this way:
    02-AUG-2012 - 08-AUG-2012
    09-AUG-2012 - 15-AUG-2012
    16-AUG-2012 - 22-AUG-2012
    23-AUG-2012 - 29-AUG-2012
    30-AUG-2012 - 05-SEP-2012
    06-SEP-2012 - 12-SEP-2012
    So, the idea is to begin the first THURSDAY after the P_FROM_DATE and at the end the Wednesday preceding the P_END_DATE...

    Thank you!

    Hello

    Here's one way:

    WITH     params          AS
    (
         SELECT  DATE '2012-08-01'     AS p_from_date
         ,     DATE '2012-09-19'     AS p_to_date
         FROM     dual
    )
    ,     end_points     AS
    (
         SELECT     TRUNC ( p_from_date + 4
                    , 'IW'
                    ) + 3          AS first_thursday
         ,     TRUNC ( p_to_date + 4
                    , 'IW'
                    ) - 5          AS last_wednesday
         FROM    params
    )
    SELECT     first_thursday + (7 * (LEVEL - 1))     AS week_start_date
    ,     first_thursday + (7 * LEVEL) - 1     AS week_end_date
    FROM     end_points
    CONNECT BY     LEVEL     <= ( last_wednesday
                      + 1
                      - first_thursday
                      ) / 7
    ;
    

    TRUNC (dt) is the beginning of the ISO week containing DATE dt.
    The 'magic number' 4 is used because the ISO week starts on Monday, 4 days later your week begins, so

    TRUNC ( dt + 4
          , 'IW'
          )
    

    is set for Monday in the same week from Thursday to Wednesday as dt.

  • Windows IT Help desk

    At 3:56 pm is I got a call from a guy who claims to be an employee with Windows IT Help Desk; Adem Smith/ID # ADM209. The call came from the following number; 69-666-6961 adem Smith gave me another number to contact him. 646 243-2811 he was telling me that my computer license has expired and so that his group to renew the license, I pay $199.00, and my computer was in danger of being hacked. Sounds a bit scammy to me.

    Anyone out there know such a group of support per person?

    Your comments will be greatly appreciated,

    Tony Capobianco

    Hello

    It's a scam.

    Either these so-called "Microsoft" Tech companies want to sell you a worthless software, or remote access to your computer to try to steal your credit card and bank information and also achieve an identity theft on you.

    You are the only person who knows if you gave them remote access.

    If you gave them remote access and you do Internet banking, contact your bank, to explain, and change passwords.

    If you use your online credit card, cancel and get a new one issued to you.

    And the only way that willl you know that you are free to them is to backup your data and do a clean install of your operating system.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    And Microsoft does not contact you unless YOU have made prior arrangements with them to do.

    There is an article in the link I'm you provide at the end of this one

    Read this Information from Microsoft:

    "Avoid scams to phone for tech support.

    http://www.Microsoft.com/security/online-privacy/avoid-phone-scams.aspx

    Don't be fooled of unsolicited calls. Don't provide personal information.

    Here are some of the organizations that cyber criminals claim to come:

    • Helpdesk Windows

    • Windows repair center

    • Microsoft technical support

    • Microsoft technical support

    • Windows Support Group Technical Department

    • Microsoft Research and Development Team (team of Microsoft R & D)

    Report phone scams

    See you soon.

  • Concerns about the workouts with the Apple Watch - request for comments and Suggestions

    I'm a professional skill that has recently upgraded from a Polar to the Apple Watch.  I am delighted to stop wearing the chest strap of the Polar, but even though I love my new watch, I wish for some improvements in the future.  Training categories are too vague.  When you set up a 'training' on my Apple Watch, which is the step class, I was ANOTHER selection to OPEN.  Others who do?  What others recommend?  And I'm trying to decide whether to use Active or Total calories during the recording of my activities in my Fitbit dashboard.  One last thing, I find it odd to be worked hard and look down to see my heart rate displayed as 60, when I know that it takes more than 130.  I would like to hear from other fitness in mind of people about my problems.  Thank you.

    Hello

    When a workout is started, choose the type of activity that best fits the nature of your exercise activity. For any activity other than the named options, select the other (for example, your step class).

    The types of activities in the application of the workout on Apple Watch help the watch to determine what sensors / data sources to use in follow-up and evaluate the results of your activity. For example:

    -To run in the open air, the watch can use the heart rate sensor, accelerometer integrated and GPS of the iPhone paired (if it is available during the race).

    -For inside running (on a treadmill), the watch will be based on the accelerometer to estimate the distance and pace (as GPS data are not relevant).

    -Indoor activities, the watch will be based mainly on the frequency heart readings to estimate of burning calories.

    The other category is therefore useful (from point of view of the watch) by advising that certain types of activities are not undertaken.

    During the follow-up of one exercise using the others, your watch will estimate active calories based on one that is the higher of:

    -L'equivalent of a brisk walk (calories saved on this basis can vary per person, based on their personal information), or;

    -The data recorded by the heart rate sensor.

    When you use the other, activity app will also credit the ring of progress of exercise with one minute for every minute of the workout.

    If you want Apple to consider adding specific types of additional activities for the purpose of the workout, you can suggest that here:

    https://www.Apple.com/feedback/watch.html

    All submissions are read (even if you do not expect to receive a response).

    More information:

    Use of the workout on your Apple Watch - Apple Support

  • iMessage misappropriation of Group Messages after cancel registration

    Hello

    I recently turned to a Samsung Galaxy phone after a series of recent frustrations with my iPhone 6.  I followed all the instructions from Apple more than a week before you switch phones, including the signing of iMessage, FaceTime, etc. and unregister iMessage on the support site.  iPhone users can now send me different SMS messages without problem, but I can't group message with the users of the iPhone, as iMessage diverts the wire and I never see any message but my own.  It is a huge problem for me because we use texts of the Group largely to work.  I opened a bug with the following report:

    Summary: After switching to an Android device and correctly following the instructions of Apple unregistered iMessage and FaceTime, I am still unable to receive messages from iPhone users group. They will receive my messages in the form of group MMS texts, but their yields are sent as iMessage and I (obviously) never received it. This has been a problem for years, but has apparently resolved. It is a major issue for anyone who switches between multiple devices.

    Steps to reproduce:

    (1) have an iPhone on a cell line with turned on iMessage.

    2) unregister iMessage and FaceTime, and then swap your SIM card in a phone Android 24 hours or more after.

    (3) send a group message to some iPhone users.

    (4) they will receive your messages as SMS/MMS, but their statements will be sent as iMessage and so lost.

    Expected results: iOS devices should recognize that the device that they sponsor is not compatible iMessage and default return of SMS/MMS Messages as expected.

    Actual results: complete failure, with iMessages lost in the ether and interrupted communication.

    Version: 9.2 / 13 c 75

    Notes:

    Configuration:

    IOS9 iPhone switched to the Samsung Galaxy S6 after following Apple recommends steps to unregister from iMessage. Also reproducible simply turn off iMessage and trying to use the SMS of traditional group on an iPhone with iOS 9.

    This is the response I got:

    Apple Developer Relations21-Dec-2015 10:17

    Engineering has provided the following information about this issue: that's right. The group, if she's never iMessage, will not downgrade to MMS. If you have had at some point in the past sent an MMS to this group we would allow downgrade of the group. Basically, if unsubscribe iMessage in one group of iMessage we don't downgrade the conversation to a weaker technology.

    I can't imagine that their strategy of engineering must divert ability group for users e-mail constantly, so I sent the following response:

    Although Apple cannot divert definitely my ability to group with iPhone users message - there must be a method to solve this problem. How did I go on group messaging with iPhone owners that use iMessage? Deletion and recreation of these threads do not work for iPhone users, even those who can me message directly, as the new thread converts iMessage and I'm still cut out of the conversation. I can't imagine that Apple engineering strategy is to break the ability to e-mail for each user who passes off the platform.

    You all have my question is this: someone could resolve this problem and resume the group messaging with iPhone via MMS instead of iMessage users after the passage? Engineering response seems like it would be incorrect (and it also seems that it would somehow illegal/immoral to permanently divert number someone if it was actually true).

    Any help you can provide would be great.

    Thank you!

    I met just that as well. I had to disable the Group MMS on my new phone just to receive texts from my roommates. It is unacceptable behavior if there is really no work around beyond disabling group MMS.

  • Issue group Variable

    I defined a TierWinDir variable with a constant value of tst. on group work, I use dev. When the job runs it does not use the value on the working group.

    Please notify. Thank you
    Warren

    Hey Warren,

    This looks like a pretty good idea and then to treat one-off measures with a different value. So, I just wanted you develop your findings a bit with a group of work variable not based on a global variable.

    Variables defined in definitions are known to be global variables (public), while the variables defined within a working group are variable local. Here at the working group level, you try to access TierWinDir.132 which is a global variable, and change its value. So, instead you create a local variable to the level of the Working Group and call the local_variable. Then the local variable can be assigned to the value of TierWinDir.132 (but not directly to the variable itself), and have passed local variable to the children jobs. And for one-offs, variable_locale values can be specified differently at the working group level.

    ARO

    The Derrick

  • 9.1 ASA + ACS 5.4 SSL Web portal bookmarks according to the ad group.

    Hello.

    Having some problems with ssl vpn on ASA 5515-X.

    I have ASA (9.1) connected to the web portal without client ssl ACS (5.4) and set up mobile client anyconnect. ACS also have connection to Active Directory.

    So he has set up this group AD users, for example, the VPN_clients connect via the anyconnect client or no client via SSL web page. And it works very well.

    My goal is to make different bookmarks portals SSL (in terms of strategies of different group ASA) according to the users AD Group.

    For example: I have 3 groups in AD: VPN_admin, VPN_Finance, VPN_Logistic. I want that the users in the group after authentication to SSL web portal would see only their own bookmarks available only for their group.

    As I inderstand once ACS authentication process must respond to ASA which the user consist of ad groups and ASA should choose the group policy right for the user, but I have no experience how to do that?

    Hello Ivan,.

    You're right, ACS can leave the ASA what group policy is to assign based on the RADIUS of the 25 attribute.

    Measures on the ACS:

    1 - definition of ad groups:

    2 set the authorization profile tab elements of the policy:

    3. create the policy and authorization access criteria:

    Then, on the ASA:

    1 create a group policy and name it.

    2. through the ASDM, create and assign bookmarks to this group policy.

    3 - once a user authenticates, the ACS sends 25 attribute, which contains the string 'OU = it'.

    4 - ASA seeks group it strategy and assigns it to the user's session.

    Let me know if you have any questions.

    HTH.

    Please note all useful messages.

  • Failed to create FT logging with grouping of NETWORK cards

    I use vSphere vCenter 5.1 and 5.1.

    I create a port group of kernel VM on a new vSwitch, assign two NICs used on my ESX Server and logging FT. I have then add a second port VM kernel group to the two network cards and also assign FT logging. When I do this FT Logging the first port of kernel VM group is disabled. If I then manually enable FT gones then a second by logging on the first group of ports of kernel VM mode off.

    The same thing happens when I create 2 vSwitches, assign 1 NIC to each of them and assign the FT logging.

    I wanted to create my FT Logging predisposees in this way to match what I've done with vMotion and VM Network.

    I do something wrong or you can have a group of ports per server for recording of FT? Please notify.

    Thank you

    Multi-NIC VMotion is a new feature in vSphere 5.0. Multi-NIC FT has not yet been introduced. You mentioned trade Multi-NIC VM, but it is not possible either. While you can have two interchanges to connect to the same VLAN they must have unique names and a VM NIC may connect only to a unique name.

    What advantage do you hope to achieve with Multi - NIC FT? If the goal is more throughput 10G is the only option currently. If the lens is better traffic load balancing so that you could watch LACP on the vDS.

  • use the sequence grouping conditional Dynamics

    Hi experts,

    I have a simple task (?) - I want number (assign) groups (increase the number of Group) based on a condition.

    Here is an example: create groups numbered according to the number of Department (as per the same collection)
    create table emp as
    select * from scott.emp;
    
    CREATE SEQUENCE group_no;
    SELECT group_no.NEXTVAL FROM DUAL;
    SELECT group_no.CURRVAL FROM DUAL;
    
    /* automatic grouping - NOT WORKING!!!! */ 
      select ename, deptno, deptno_next, deptno_prev, 
       case when (deptno_next > deptno) then group_no.nextval else 1 end grp 
        from
          (select ename, deptno,
                  lead(deptno) over (order by deptno) deptno_next,
                  lag(deptno) over (order by deptno) deptno_prev
          from emp
          );
    PROBLEM:
    It seems that the sequence is increased, even when the condition for a new number is not satisfied!
    NAME      DEPTNO                 DEPTNO_NEXT            DEPTNO_PREV            GRP                    
    ---------- ---------------------- ---------------------- ---------------------- ---------------------- 
    CLARK      10                     10                                            1                      
    KING       10                     10                     10                     1                      
    MILLER     10                     20                     10                     130                    
    JONES      20                     20                     10                     1                      
    FORD       20                     20                     20                     1                      
    ADAMS      20                     20                     20                     1                      
    SMITH      20                     20                     20                     1                      
    SCOTT      20                     30                     20                     135                   
    WARD       30                     30                     20                     1                      
    TURNER     30                     30                     30                     1                      
    ALLEN      30                     30                     30                     1                      
    JAMES      30                     30                     30                     1                      
    BLAKE      30                     30                     30                     1                      
    MARTIN     30                                            30                     1
    Instead of
    else 1
    I use group_no.currval (same group number, when does not change do not Department). I know, I need to cover the previous number as well, but I did simple, because the problem here seems to be the sequence...

    Forward your support :-)
    Duik

    Published by: user10939560 on 08.10.2012 07:42

    Published by: user10939560 on 08.10.2012 07:44

    Published by: user10939560 on 08.10.2012 07:45

    Published by: user10939560 on 08.10.2012 07:48

    Published by: user10939560 on 08.10.2012 07:49

    "I want number (assign) groups (increase the number of Group) based on a condition."

    But he did exactly want you want. The number of groups is increasing. It is not contiguous, which
    You can not guarantee for sequences of anyway.

    However, if I understand you correctly, it's maybe you need:

          select ename,deptno,
          dense_rank() over (order by deptno) grp
          from emp;
    

    If this isn't the case, please explain in more detail what you are trying to do.

    Published by: Paul Horth on October 8, 2012 08:06

  • Adding a competitor to a group of request with FNDLOAD

    Hi gurus...

    I add a new competitor to a group of application that already exists.
    Definition of this competitor has been downloaded successfully to the environment of production using FNDLOAD

    Now, I want to add this competitor to the request using FNDLOAD group

    Option 1 - transfer to production environment this unique addition to the Group of demand.
    Option 2: definition of Group of any download with the new simultaneous addition request

    What should I do?

    In the case of Option 1... How my FNDLOAD should look like, both for download and download?

    Thanks in advance
    Oscar

    If you change objects that are sown, future corrections back your changes.

    You will need to download the simultaneous program definitions and the application group, and then load them into the target instance - which means that the levels of EBS patch on source and target texts are identical.

    The other option is to download the definition of competitor program only, the same Uploader in the target, and then manually add the concurrent program in the application group

    HTH
    Srini

  • No Group by or jump on the additional Pages...

    Hello
    I was able to get a great use to repeat my point to several pages group - wire: "group of the item Display on each Page. This was the first item in the table above, but I have another question to try to achieve but the group not having per item (s) in the tabular presentation. I have a model complex .rtf and I can't figure how to get back on some field values that exist within the tabular presentation. The values do not appear on the next page if the records continue to the next page. This occurs only when no page break or group by occurs. Thus, the data is displayed with no space and no domain name. Can someone help me with this? I can send my .rtf model and also to include a screenshot of exactly what is happening. Thanks for reading in advance.

    check the other example of output sent to your email address.

Maybe you are looking for

  • functions of the menu bar missing?

    I just noticed that when I turn off the menu bar function to use the Firefox drop-down list certain functions that appear in the menu bar are missing in drop-down screen for example file and view. If they are present, I can't find them or there at -

  • What does clear and reset doo bought items such as apps?

    I have an iPad 4. What's doing to my purchased items, such as applications are erased and reset?

  • Satellite L450D-113 vs Sat Pro L450D-13 x - touchpad issue

    Good day for a novice. I bought a Satellite L450D and the touchpad's door as well as the left button is tired.I want to replace the entire palmrest with buffer and ebay buttons but cannot see examples of Satellite L450D Pro offer. Are they interchang

  • Windows XP does not correctly initialize after virus removal

    I am running Windows XP Home SP3 with FF 5.0.  I had a virus (Backdoor.RBot) the Avast program not found. Nor have programmed the MRT of Microsoft, or the online scanner. Used Malwarebytes and the virus has been removed. Installed Microsoft Security

  • PSC 1210xi all in one is not responding

    My psc 1210xi all in one does not. I was able to use the copy feature stand alone and also print a document from my hp laptop (Windows 7) successfully last night. (After plugging on this laptop for the first time by the way.) Now I am trying to print