Rank of computed column is not work

Hello PL/SQL gurus and experts.


I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version
I have table-

drop table t3;
create table t3(Pat_NM,Hospital,Test_Range,Total,LyTotal) as select
'Andy','Batra','> 10 Mph','20000','20000' from dual union all select
'Andy','Fortis','1-3 Mph','24500','20000' from dual union all select
'Andy','Max','5-10 Mph','10600','20000' from dual union all select
'Andy','Max','5-10 Mph','22500','20000' from dual union all select
'Andy','Aashiana','5-10 Mph','110600','20000' from dual union all select
'Andy','Amar','5-10 Mph','34800','20000' from dual union all select
'Andy','Max','5-10 Mph','600','20000' from dual union all select
'Andy','Columbia','< 1 Mph','27700','20000' from dual union all select
'Andy','Nimhans','< 1 Mph','50000','20000' from dual union all select
'Andy','Meenam','< 1 Mph','11000','20000' from dual union all select
'Andy','Meeran','5-10 Mph','24625','20000' from dual union all select
'Andy','Mnagamani','> 10 Mph','12000','20000' from dual union all select
'Andy','Murari','> 10 Mph','20600','20000' from dual union all select
'Andy','Triveni','5-10 Mph','16500','20000' from dual union all select
'Cindy','Batra','5-10 Mph','14700','20000' from dual union all select
'Cindy','Max','< 1 Mph','170000','20000' from dual union all select
'Cindy','Apollo Medical Centre','> 10 Mph','19000','20000' from dual union all select
'Cindy','MLal','1-3 Mph','22600','20000' from dual union all select    
'Cindy','Columbia','< 1 Mph','28900','20000' from dual union all select
'Cindy','Asian','1-3 Mph','27900','20000' from dual union all select
'Cindy','Mahagun','< 1 Mph','28700','20000' from dual union all select
'Cindy','Manipal','< 1 Mph','29040','20000' from dual union all select
'Cindy','Prestige','< 1 Mph','12700','20000' from dual union all select
'Cindy','A.G.M.','< 1 Mph','97800','20000' from dual union all select
'Cindy','Shobha','< 1 Mph','700','20000' from dual union all select
'Cindy','Aashiana','5-10 Mph','23450','20000' from dual union all select
'Cindy','Amar','1-3 Mph','21325','20000' from dual union all select
'Cindy','Childs Trust','5-10 Mph','22775','20000' from dual union all select
'Cindy','Crescent ','< 1 Mph','20025','20000' from dual;

I have an Anlzd rank as this logic folloing calculation-
Ranking ((Cy Yr Tot *Factor-Prev Yr Tot) /Prev year Tot)

and it does not correct-

Currently I use the following DML-

select Pat_NM,
decode(grouping(Test_Range), 0, Test_Range, 'Total') "Test Range",
Hospital,
SUM (Total) "Total",
SUM (AnlzdTotal) "Anlzd Total",
SUM (LyTotal) "Last Yr Total",
decode(grouping(Test_Range), 0, max(rank), null) Rank,
decode(grouping(Test_Range), 0, max(lyrank), null) "Anlzd Rank"
from
(Select Pat_NM,
         Hospital,
         Test_Range,
         SUM (Total) Total,
  SUM (AnlzdTot) AnlzdTotal,
  SUM (LyTotal) LyTotal,
         DENSE_RANK ()
            OVER (PARTITION BY test_range || pat_nm ORDER BY SUM (LyTotal) DESC)
            AS LYRANK,
 DENSE_RANK ()
            OVER (PARTITION BY test_range || pat_nm ORDER BY SUM (Total) DESC)
            AS RANK,
         ROW_NUMBER ()
            OVER (PARTITION BY test_range || pat_nm ORDER BY SUM (Total) DESC)
            AS rk
from
(
SELECT Pat_NM,
         Hospital,
         Test_Range,
         SUM (Total) Total,
  SUM (LyTotal) LyTotal,
  sum (Total) *1.85 AnlzdTot,
  (sum (Total * 1.85 - LyTotal)/nullif(sum(LyTotal),0)) AnlzdTotRank         
    FROM t3
GROUP BY Pat_NM, Hospital, Test_Range
)
group by Pat_NM, Hospital, Test_Range)
group by grouping sets((Pat_NM, Test_Range,Hospital),())
order by Pat_NM,Test_Range, Rank;

Output data, I'm getting-

PAT_N Test Ran HOSPITAL                   Total Anlzd Total Last Yr Total       RANK Anlzd Rank
----- -------- --------------------- ---------- ----------- ------------- ---------- ----------
Andy  1-3 Mph  Fortis                     24500       45325         20000          1          1
Andy  5-10 Mph Aashiana                  110600      204610         20000          1          2
Andy  5-10 Mph Amar                       34800       64380         20000          2          2
Andy  5-10 Mph Max                        33700       62345         60000          3          1
Andy  5-10 Mph Meeran                     24625    45556.25         20000          4          2
Andy  5-10 Mph Triveni                    16500       30525         20000          5          2
Andy  < 1 Mph  Nimhans                    50000       92500         20000          1          1
Andy  < 1 Mph  Columbia                   27700       51245         20000          2          1
Andy  < 1 Mph  Meenam                     11000       20350         20000          3          1
Andy  > 10 Mph Murari                     20600       38110         20000          1          1
Andy  > 10 Mph Batra                      20000       37000         20000          2          1
PAT_N Test Ran HOSPITAL                   Total Anlzd Total Last Yr Total       RANK Anlzd Rank
----- -------- --------------------- ---------- ----------- ------------- ---------- ----------
Andy  > 10 Mph Mnagamani                  12000       22200         20000          3          1
Cindy 1-3 Mph  Asian                      27900       51615         20000          1          1
Cindy 1-3 Mph  MLal                       22600       41810         20000          2          1
Cindy 1-3 Mph  Amar                       21325    39451.25         20000          3          1
Cindy 5-10 Mph Aashiana                   23450     43382.5         20000          1          1
Cindy 5-10 Mph Childs Trust               22775    42133.75         20000          2          1
Cindy 5-10 Mph Batra                      14700       27195         20000          3          1
Cindy < 1 Mph  Max                       170000      314500         20000          1          1
Cindy < 1 Mph  A.G.M.                     97800      180930         20000          2          1
Cindy < 1 Mph  Manipal                    29040       53724         20000          3          1
Cindy < 1 Mph  Columbia                   28900       53465         20000          4          1
PAT_N Test Ran HOSPITAL                   Total Anlzd Total Last Yr Total       RANK Anlzd Rank
----- -------- --------------------- ---------- ----------- ------------- ---------- ----------
Cindy < 1 Mph  Mahagun                    28700       53095         20000          5          1
Cindy < 1 Mph  Crescent                   20025    37046.25         20000          6          1
Cindy < 1 Mph  Prestige                   12700       23495         20000          7          1
Cindy < 1 Mph  Shobha                       700        1295         20000          8          1
Cindy > 10 Mph Apollo Medical Centre      19000       35150         20000          1          1
      Total                              925640     1712434        580000

I want to - data

PAT_N Test Ran HOSPITAL                   Total Anlzd Total Last Yr Total       RANK Anlzd Rank
----- -------- --------------------- ---------- ----------- ------------- ---------- ----------
Andy  1-3 Mph  Fortis                     24500       45325         20000          1          1
Andy  5-10 Mph Aashiana                  110600      204610         20000          1          1
Andy  5-10 Mph Amar                       34800       64380         20000          2          2
Andy  5-10 Mph Max                        33700       62345         60000          3          5
Andy  5-10 Mph Meeran                     24625    45556.25         20000          4          3
Andy  5-10 Mph Triveni                    16500       30525         20000          5          4
Andy  < 1 Mph  Nimhans                    50000       92500         20000          1          1
Andy  < 1 Mph  Columbia                   27700       51245         20000          2          2
Andy  < 1 Mph  Meenam                     11000       20350         20000          3          3
Andy  > 10 Mph Murari                     20600       38110         20000          1          1
Andy  > 10 Mph Batra                      20000       37000         20000          2          2
PAT_N Test Ran HOSPITAL                   Total Anlzd Total Last Yr Total       RANK Anlzd Rank
----- -------- --------------------- ---------- ----------- ------------- ---------- ----------
Andy  > 10 Mph Mnagamani                  12000       22200         20000          3          3
Cindy 1-3 Mph  Asian                      27900       51615         20000          1          1
Cindy 1-3 Mph  MLal                       22600       41810         20000          2          2
Cindy 1-3 Mph  Amar                       21325    39451.25         20000          3          3
Cindy 5-10 Mph Aashiana                   23450     43382.5         20000          1          1
Cindy 5-10 Mph Childs Trust               22775    42133.75         20000          2          2
Cindy 5-10 Mph Batra                      14700       27195         20000          3          3
Cindy < 1 Mph  Max                       170000      314500         20000          1          1
Cindy < 1 Mph  A.G.M.                     97800      180930         20000          2          2
Cindy < 1 Mph  Manipal                    29040       53724         20000          3          3
Cindy < 1 Mph  Columbia                   28900       53465         20000          4          4
PAT_N Test Ran HOSPITAL                   Total Anlzd Total Last Yr Total       RANK Anlzd Rank
----- -------- --------------------- ---------- ----------- ------------- ---------- ----------
Cindy < 1 Mph  Mahagun                    28700       53095         20000          5          5
Cindy < 1 Mph  Crescent                   20025    37046.25         20000          6          6
Cindy < 1 Mph  Prestige                   12700       23495         20000          7          7
Cindy < 1 Mph  Shobha                       700        1295         20000          8          8
Cindy > 10 Mph Apollo Medical Centre      19000       35150         20000          1          9
      Total                              925640     1712434        580000

Thanks in advance for all your efforts, time and valuable feedback.

Thanks for the comments FrankKulash, I checked that it was due to the "last nulls' to be added in the following lines.

DENSE_RANK)

COURSES (PARTITION BY test_range | pat_nm ORDER OF SUM (LyTotal) / / DESC nulls last)

AS LYRANK,

DENSE_RANK)

COURSES (PARTITION BY test_range | pat_nm ORDER OF SUM (Total) / / DESC nulls last)

IN THE RANK,.

DENSE_RANK)

COURSES (PARTITION BY test_range | pat_nm ORDER OF SUM (AnlzdTotRank) / / DESC nulls last)

AS ANLZDRANK,

ROW_NUMBER)

COURSES (PARTITION BY test_range | pat_nm ORDER OF SUM (Total) / / DESC)

AS rk

Tags: Database

Similar Questions

  • Once I changed my ISP my computer network does not work and does not recognize my router lynsys

    Once I changed my ISP my computer network does not work and does not recognize my router lynsys

    Hi George,.
    Please go to the Microsoft Community Forums.
     
    1. do you get an error message?
    2. do you have the internet connection wired or wireless?
    3. What is the brand and model of the computer?
     
    I suggest to refer to the links and follow the steps in the articles:
     
    Wireless and wired network problems
     
    Resources for the resolution of the problems of modem in Windows XP
     
    How to troubleshoot wireless network connections in Windows XP Service Pack 2
     
    How to reset the Protocol Internet (TCP/IP)
     
    If the problem persists, contact the Internet service provider for assistance.
     
    I hope this helps.
  • touchpart of the labtop computer mouse does not work

    problems using my arrow
    not controllable somehow more flashes arround what could be occasionally a mouse extern?

    Hi Oskarchristian,

    Thanks for posting your query in the Microsoft Community Forums.

    It looks like that your touch pad is not working.

    I would appreciate if you can help me with the following information.

    1. what version of Windows you are using on the computer?

    2. What is the number of brand and model of the computer?

    3. don't you make changes on the computer before this problem?

    I suggest you to refer to the help article and check if it helps.

    Mouse, touchpad and keyboard with Windows problems

    http://Windows.Microsoft.com/en-us/Windows/help/Mouse-touchpad-and-keyboard-problems-in-Windows?T1=tab05

    It will be useful.

    Let us know if you encounter problems under Windows in the future. We will be happy to help you.

  • Computer management does not work in Windows XP Pro

    I am constantly the error box who run the States "Computer management is not available on this system" any if I execute the command line, use the administrative tools or right-click on "My computer" and select from the list of options.

    The computer was scanned for viruses (negative) with MalwareBytes, Avast and McAfee online analysis with all showing a certificate of good health.
    I am running Windows XP Pro with service pack 3.  The computer has 1 GB of memory and a 160 GB hard drive with a dual core cpu.  It works well with other versions of the OS boot from the CD (live disks) without problems, but continues to have problems with 'users' XP trying to view / change anything the computer management or the Panel applet 'users and groups '.
    I have three users (Admin, User1 and User2) with only the administrator with full administrator privileges, others have restricted the user which is also defined under 'users and groups' status in the management console.  Users have a bit of data stored on the disks, a re - install is not a favorable option if it turns out be destructive.
    I'm open to suggestions / comments that are helpful and constructive in nature.
    Thanks in advance.
    Chuck.

    Hi Chuck,

    ·         Have you made changes on the computer before this problem?

    Follow these methods.

    Method 1: Scan the file system (CFS) auditor to repair corrupted files.

    Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe)

    http://support.Microsoft.com/kb/310747

    Method 2: Create a new user account.

    How to create and configure user accounts in Windows XP

    http://support.Microsoft.com/kb/279783

    For reference:

    When I tried to open Device Manager or the computer management window, I received an error message: "MMC cannot open the file C:\WINDOWS\system32\devmgmt.msc.

    http://support.Microsoft.com/kb/914231

  • Computer management does not work

    When I right click on computer and select "Manage", nothing happens. Similarly, when I click on Administrative Tools > computer management, nothing happens. I also tried to activate the management of the computer to c:\windows\system32\CompMgmtLauncher.exe. Yet once, nothing happens. How can I get the computer management to run? I have Vista Home Premium SP2.

    Try to enter compmgmt.msc in start / search box and enter.  Double-click the program icon that appears and see if it opens.  I doubt that it will work if clicking on the executable file did not work, but it's worth a try.

    We will check some of your system files:

    Go to start / all programs / accessories / command prompt and right click on command prompt, and then click Run as administrator.

    Type sfc/scannow, go and let it run.  It will scan and try to fix some system files.  If all goes well, it will finish without any error, it could not repair (if these errors occur, post here).

    While you're in prompt type chkdsk /f /r command and enter and let it run.  It will search for and fix/mark bad sectors (and management of computer files can be in a bad sector that can be moved unless it is irreparably damaged).

    Are you sure that the problem is limited to the management of the computer / have you tried to enter EventViewer or anyghing elsewhere in Services management tools?  Please try.

    You have a disk for Installation of Windows Vista genuine (or you can borrow one from ANYONE).  If none of these efforts works, our next logical step would be a repair system/upgrade and we need the disk to do so.  They are not protected against copying in order to use all copy with your own product key which governs the installed version.

    Let's see where this gives us.  Good luck and I hope this helps.  If she's not really try hard to get your hands on a disc. Lorien - a - MCSE/MCSA/network + / A +.

  • Start &#62; Panel &#62; system and security &#62; your computer backup does not work

    When I click 'save your computer' nothing happens. I tried all the solutions I found here and other forums. I checked the level backup engine service block, Volume Shadow Copy and backup Windows are set to automatic and are running. I ran sfc and he found no problem.  I am able to start sdclt.exe / configure in a command window and it runs and gets "Starting Windows Backup followed by implementing backup...". and more of what seems to be OK.

    I can't just start it fron Control Panel. Everything else on the control panel works fine.

    Help, please

    JJ

    Hello
     
    1. what exactly happens if you mean when you talk about "clean boot does not work? Please provide details.
    2. have you tested the issue in a new user account, as suggested earlier?
     
    Boot fails only when you have disabled a vital service of Microsoft (S). You must observe extreme caution when performing the clean boot procedure.
     
    Note: Don't forget to restart your computer as usual after the clean boot.
     
    PS: Your son is better suited to the Performance category, so this would be moved (Again) to performance and maintenance

    Aziz Nadeem - Microsoft Support

    [If this post was helpful, please click the button "Vote as helpful" (green triangle). If it can help solve your problem, click on the button 'Propose as answer' or 'mark as answer '. [By proposing / marking a post as answer or useful you help others find the answer more quickly.]

  • Date filter column does not work

    Hello

    I use jdeveloper 11.1.2.4.

    I have a table with a side of column and the date filter.

    The date comes from a view object, based on an attribute of type Timestamp.

    The format is: MM/DD/YYYY.

    When I enter a date or choose a date in the date picker and press on enter the table is empty.

    I expect to get the correct filtered lines.

    This is my code:

    It is a simple code created when I did drag the view from data on page tabular controls.

    I got to it.

     <af:column sortProperty="#{bindings.MyView.hints.MyDate.name}"
                                                   filterable="true" sortable="true"
                                                   headerText="#{bindings.MyView.hints.MyDate.label}"
                                                   id="c9">
                      <f:facet name="filter">
                            <af:inputDate value="#{vs.filterCriteria.MyDate}" id="id2">
                                    <af:convertDateTime pattern="#{bindings.MyView.hints.MyDate.format}"/>
                             </af:inputDate>
                       </f:facet>
                       <af:outputText value="#{row.MyDate}"
                                              shortDesc="#{bindings.MyView.hints.MyDate.tooltip}"
                                              id="ot8">
                                            <af:convertDateTime pattern="#{bindings.MyView.hints.MyDate.format}"/>
                       </af:outputText>
         </af:column>
    

    Could you help her?

    Why the date filter does not work?

    Thank you very much!

    Thus, it is a problem.

    In order to work, you must somehow truncating HH part, the same as if you were doing SQL tronque().

    There are several ways to do it, but, maybe you can change SQL of VO and add a new truncated attribute one?

    And rather original attr, you can filter a new?

    Also, take a look at:

    Oracle ADF 11 g tips: September 2011

  • 15 - ac 122tu: 15 - AC laptop computer 122tu WIFI not working not not on OS linux-Mint

    Hello

    I buy my new laptop HP 15 - ac 122tu now I have installed linux mint on my system. But I am facing problem WIFI it does not work on my system. Please tell what I need to do. Need driver or extra.

    Hi @kamalkishore,

    If questions may need to replace the network adapter.

    Please use the following http://www.hp.com/contacthp and create a folder for your question and contact HP. If you do not live in the United States / Canada, please click on the link below to get contact information for your region.
    http://WWW8.HP.com/us/en/contact-HP/WW-phone-assist.html

  • Laptop computer internal speakers not working not

    My DELL INSPIRON Laptop speakers - do not work! - only a high-pitched shrill, strong is heard any audio presentation! - external head set microphone work perfectly well!

    From Internet Explorer

    Original title: LAP TOP speakers INTERNS.

    My DELL INSPIRON Laptop speakers - do not work! - only a high-pitched shrill, strong is heard any audio presentation! - external head set microphone work perfectly well!

    From Internet Explorer

    Original title: LAP TOP speakers INTERNS.

    If you start with a Linux Live CD to somehow play a few sounds - is the result the same?
    If so - download the repaired hardware.

  • Sony Vaio VGN-NW120J computer laptop speakers not working do not... However, I can hear low sound when I connect external speakers or headphones

    In fact it has window vista family premium as window by default, but I changed it to home premium to Windows 7. But the speaker does not work (no), but when I connect the headphones the sound comes with a very low volume. So what could be the problem and how can I solve it.

    This is why I would be grateful for your help.

    Hi Somzil,

    To address this concern, we suggest you follow these steps on how to manage the properties of speaker of your device:

    1. Click Start, then click Control Panel.
    2. Click sounds and in the playbacktab, click speakers, and then click on Properties.
    3. New window opens as properties of speakers, then click on improvements.
    4. Check volume equalization.

    You can also see the steps on how to update your Audio driver and run the Audio troubleshooter under the title of the problems of sound on this link: the sound problems.

    We also recommend you to contact the manufacturer of the device to get help on this problem.

    Let us know how it goes.

    Thank you.

  • Speakers Realtek HDAudio work for the computer, but do not work for Microsoft or Quicken help video. What do I need to get this to work?

    Speaker test are ok and music disc play like UTube.

    Most often when a device does not work, it is because the driver is damaged. Re-install a new copy should help

    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly? SignedIn = 1

  • 15 - BE001TX: computer laptop speakers not working with my mobile phone in A2DP

    I installed all the drivers available on the hp support site appropriate for my machine.

    I also downloaded the following bluetooth aetheros.

    My machine shows connection to the device and the dialog box appears with the current song is played in mobile, but I can't hear any sound from my laptop speakers.

    Hi @shrayank,

    Thank you for your query. I will do my best to help.

    I understand that even if your Bluetooth device is connected and the song shows as not playing in the dialog box, you have no sound from speakers. Here is a link to HP computers - use of devices Bluetooth (Windows 10: 8). Everything by doing some research, I found this document which may help. How Stream songs from phone to computer via Bluetooth. The device you're using may not be a phone, but the steps may help. Please let me know what worked for you, if the problem is resolved.

    Please let me know if that solves the problem by marking this post as 'Accept as Solution'. "To simply say thank you, click on the" ","inch Up ' below!   If you need more assistance let me know and I will gladly do everything I can to help.

  • 2 text flow 2 individual images for column span column does not work

    Can I put in place of master pages so that each page has a 2 col frame and cover so setting column works?

    Thanks for the help.

    Jon

    OK, I think I know what is happening.

    Primary text blocks behave a little differently blocks of ordinary text on the master page. With a regular set of frames related masters, you hold down the SHIFT key when you move the text to enable auto-flux of an image to the image and have automatically added images and pages. Primary text blocks are designed to work with Smart Text Reflow and you simply click the cursor loaded inside of them and STR returns to add pictures and pages. If you hold down the SHIFT key while trying to text in a primary text block which frame is skipped, and new ordinary frames are drawn by using your column guides. You can see that cheek if you look at the cursor loaded – as soon as you press the SHIFT key, it will pass icon text in parentheses (to indicate that the text will be placed into an existing framework) the boom wave within a difficult angle (to indicate the text will be "automatic formatting" in a thread of new frameworks rather than use any existing framework).

    Set up your document originally with two columns, which makes your main text frame a frame of two columns, but this also means that if the main frame is ignored during the auto-flux, you will get two independent columns per page.

    Bottom line here is just a click away within your framework and not hold down the SHIFT key. And turn on Smart Text Reflow to primary in the preferences text blocks if you had it.

  • filter on a column does not work? PHP

    I have a column (payment_type) in the php database that is in a table called host_payments. It has values that can be called 'depot' in the column

    I want to exclude this value

    I made my request

    "SELECT * FROM plus_signup, host_payments WHERE plus_signup.userid = host_payments.payment_userid AND plus_signup.latestPaymentMade = 0 AND plus_signup.payment_option = 1 AND host_payments.payment_type = 'deposit" ";

    It works and appears all the records that have deposit and works very well, but then I add exclusion

    "SELECT * FROM plus_signup, host_payments WHERE plus_signup.userid = host_payments.payment_userid AND plus_signup.latestPaymentMade = 0 AND plus_signup.payment_option = 1 AND host_payments.payment_type! = "deposit" «;"

    Then, I get the error return

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near '! = ' deposit "on line 1

    I tried not to mention the "depot" and changed to file

    then get the following error

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near '! deposit =' at line 1

    can someone give me advice?

    Thank you

    It's pure speculation, but it might be worth trying:

    "SELECT * FROM plus_signup, host_payments WHERE host_payments.payment_type! = 'depot' AND (plus_signup.userid = host_payments.payment_userid AND plus_signup.latestPaymentMade = 0 AND plus_signup.payment_option = 1) ";

  • How to get adobe flash appears as a plug-in, it is on my computer but is not working or appear in firefox

    I have the last flash to adobe downloaded on my computer. but it does not appear as an available in firefox plug. When I go to sites that require flash they say that flash is not loaded. I don't have the problem when using chrome or ie can you help me? I read related post, but haven't seen a response.

    Separate issue
    Shows details of the system;

    Plug-ins installed

    Version 0.9.19, Copyright 2006 - 2012 Veetle Inchttp: / /www.veetle.com/
    Version 0.9.18, copyright 2006-2010 Veetle Inchttp: / /www.veetle.com/

    Having multiple versions of a program can cause problems.

Maybe you are looking for