a kind of cumulative number

Hello

I'm fighting to get a sort of running a table number, but I can't do it without a view... But maybe there is a better way to do it.

The table is:

ID     CAT_ID     NAME     FLAG
1     2     AAA          null
2     2     BBB          A
3     2     CCC          A
4     2     DDD          null
5     4     AAA          null
6     2     EEE          B
7     2     FFF          A

And I need to count the flag 'A' for CAT_ID = 2, the result should be like:

ID     CAT_ID     NAME     FLAG     COUNT
1     2     AAA          null          0
2     2     BBB          A          1
3     2     CCC          A          2
4     2     DDD          null          2
6     2     EEE          B          2
7     2     FFF          A          3

Please notify.

Thank you!

CASES plus number of race through Analytics, something like this:

SELECT location_id, country_id, COUNT(CASE WHEN country_id='US' THEN 1 END) OVER (ORDER BY location_id)

Sites

ORDER BY 1

Tags: Database

Similar Questions

  • Cumulative number of separate

    Hello

    I have a question about the analytical functions. What I'm trying to achieve is: calculate the cumulative number of separate.

    For example, to 20091001 I need to count the distinct subscribers on this date. I have need to also consider 20091001 to 20091002. 20091003 I must consider 20091001 to 20091002. You got the point.

    Below, I have attached the input data and also my goal. I tried some of the windowing functions with no luck.

    With 10 gr 2 Enterprise edition

    Thank you
    Onur


    DATA:
    daily_calendar_id subsriber_id
    20091001 1
    20091001 3
    4 20091001
    20091001 3
    4 20091001
    5 20091001
    20091001 6
    20091001 2
    4 20091001
    20091001 1
    20091001 1
    20091001 3
    20091002 7
    20091002 8
    20091002 3
    20091002 2
    20091002-1
    20091002 5
    20091002 12
    10 20091003
    12 20091003
    4 20091003
    6 20091003
    4 20091003
    3 20091003
    4 20091003
    17 20091003
    16 20091003
    20091004 17
    20091004 18
    20091004 19
    20091004 20
    20091004-1
    20091004 2
    20091004 21


    EXPECTED RESULT:
    daily_calendar_id Cumulative_distinct_subscriber_count
    20091001 6
    20091002 9
    12 20091003
    20091004 16

    Published by: user6299691 on December 10, 2009 05:04
    with t
    as
    (
    select 20091001 dt, 1 val from dual union all
    select 20091001, 3 from dual union all
    select 20091001, 4 from dual union all
    select 20091001, 3 from dual union all
    select 20091001, 4 from dual union all
    select 20091001, 5 from dual union all
    select 20091001, 6 from dual union all
    select 20091001, 2 from dual union all
    select 20091001, 4 from dual union all
    select 20091001, 1 from dual union all
    select 20091001, 1 from dual union all
    select 20091001, 3 from dual union all
    select 20091002, 7 from dual union all
    select 20091002, 8 from dual union all
    select 20091002, 3 from dual union all
    select 20091002, 2 from dual union all
    select 20091002, 1 from dual union all
    select 20091002, 5 from dual union all
    select 20091002, 12 from dual union all
    select 20091003, 10 from dual union all
    select 20091003, 12 from dual union all
    select 20091003, 4 from dual union all
    select 20091003, 6 from dual union all
    select 20091003, 4 from dual union all
    select 20091003, 3 from dual union all
    select 20091003, 4 from dual union all
    select 20091003, 17 from dual union all
    select 20091003, 16 from dual union all
    select 20091004, 17 from dual union all
    select 20091004, 18 from dual union all
    select 20091004, 19 from dual union all
    select 20091004, 20 from dual union all
    select 20091004, 1 from dual union all
    select 20091004, 2 from dual union all
    select 20091004, 21 from dual
    )
    select dt, sum(cnt) over(order by dt) cnt
      from (
    select dt, count(*) cnt
      from (select min(dt) dt
             from t
            group by val)
     group by dt)
    
  • Cumulative NUMBER

    Hello

    Anyone know how I can reach a cumulative number?

    For example, I have the select statement:

    Select deptno from scott.emp

    20
    30
    30
    40
    20
    10

    what I get is the following:

    DEPTNO County

    20 1
    30 2
    30 2
    40 3
    20 3
    4 of 10

    I'm playing my mind with analithycal functions, but without result so far.

    Have a tip?

    Thank you in advance!

    Published by: user817006 on January 23, 2009 06:15

    user817006 wrote:
    No, he should count on all ranks, how many separate departments are to this day. Like this:

    Well you shouldn't change your needs when someone is already working on it. ; P

    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, sum(rn) over (partition by 1 order by empno) cnt
      2  from (
      3    select empno, deptno, decode(row_number() over (partition by deptno order by empno),1,1,0) rn
      4    from emp
      5    )
      6* order by empno
    SQL> /
    
        DEPTNO        CNT
    ---------- ----------
            20          1
            30          2
            30          2
            20          2
            30          2
            30          2
            10          3
            20          3
            10          3
            30          3
            20          3
            30          3
            20          3
            10          3
    
    14 rows selected.
    
    SQL>
    
  • How to get essbase excel add in the display of the total cumulative number?

    Version 11.1.2.1

    When I connect firstly in my ASO application via the excel add-in, the first thing I see is a null value. My first dimension/column is 'period '. Period is marked as a dynamic calc and label only.

    When I drill down in the period I see obviously all rollup values. How can I get the excel to display the full cumulation (instead of having to drill down) when I connect firstly because I like to keep my options as ' delete missing values / zeros "checked.

    I see in Sample.Basic is 105522. I want something like that. I tried reloading the numbers and changed the properties without result.

    What is the logic behind this?

    If "Period" is marked as 'Label only' it will take the value of her first child, if the first child has a value of #Missing, then "Period" also will display a value of #Missing. If you want to 'Period' to show all the periods (as Sample.Basic does) then you need to take off the "Label" label only

  • Using SQL cumulative number

    Hi guys,.

    I have the following sql query:
    select trim(to_char(to_date(substr(assn.creationdate,
                                       0,
                                       instr(assn.creationdate, ':', 1, 3) - 1),
                                'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                        'mm')) || ' - ' ||
           to_char(to_date(substr(assn.creationdate,
                                  0,
                                  instr(assn.creationdate, ':', 1, 3) - 1),
                           'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                   'YYYY') as par_date,
           (case
             when prochis.stateoutreq = 't1Issued' then
              'A-Submit'
             when prochis.stateoutreq = 'LcsRejected' then
              'A-Return'
             when prochis.stateoutreq = 't3RevResp' then
              'A-Return'
             when prochis.stateoutreq = 'CcfReview' then
              'A-Return'
             when prochis.stateoutreq = 't3Validated' then
              'A-Return'
           end) as par_stage,
           count(case
                   when (prochis.processname = 't3_AWD_Awaiting_Cust_Response') then
                    1
                   when (prochis.processname = 't3_AWD_Send_PAR') then
                    1
                   when (prochis.processname = 't3_AWD_Send_PAR_PartB') then
                    1
                   when (prochis.processname = 't3_AWD_Await_PAR_B_Response') then
                    1
                 end) as par_stage_count
      from awdbt1m4.cmchrqit par
      left outer join ttcadminref@TCDWHS aref
        on par.lifecyclestate = aref.short
     inner join awdbt1m4.asgsig assn
        on assn.left = par.obid
     inner join awdbt1m4.prochist prochis
        on assn.right = prochis.obid
     where (case
             when prochis.stateoutreq = 't1Issued' then
              'A-Submit'
             when prochis.stateoutreq = 'LcsRejected' then
              'A-Return'
             when prochis.stateoutreq = 't3RevResp' then
              'A-Return'
             when prochis.stateoutreq = 'CcfReview' then
              'A-Return'
             when prochis.stateoutreq = 't3Validated' then
              'A-Return'
             when prochis.statein = 't3IssPartB' then
              'B-Submit'
             when prochis.stateoutreq = 't3RevPartB' then
              'B-Return'
             when prochis.stateoutreq = 't1FinRev' then
              'B-Return'
           end) is not null
       and prochis.stateoutreq in
           ('t1Issued', 'LcsRejected', 't3RevResp', 'CcfReview', 't3Validated')
       and prochis.lifecyclename = 'PAR Lifecycle'
     group by trim(to_char(to_date(substr(assn.creationdate,
                                          0,
                                          instr(assn.creationdate, ':', 1, 3) - 1),
                                   'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                           'mm')) || ' - ' ||
              to_char(to_date(substr(assn.creationdate,
                                     0,
                                     instr(assn.creationdate, ':', 1, 3) - 1),
                              'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                      'YYYY'),
              (case
                when prochis.stateoutreq = 't1Issued' then
                 'A-Submit'
                when prochis.stateoutreq = 'LcsRejected' then
                 'A-Return'
                when prochis.stateoutreq = 't3RevResp' then
                 'A-Return'
                when prochis.stateoutreq = 'CcfReview' then
                 'A-Return'
                when prochis.stateoutreq = 't3Validated' then
                 'A-Return'
              end)
     order by par_stage
    and I want to make a sum accumulated on the results returned by
     count(case
                   when (prochis.processname = 't3_AWD_Awaiting_Cust_Response') then
                    1
                   when (prochis.processname = 't3_AWD_Send_PAR') then
                    1
                   when (prochis.processname = 't3_AWD_Send_PAR_PartB') then
                    1
                   when (prochis.processname = 't3_AWD_Await_PAR_B_Response') then
                    1
                 end) as par_stage_count
    contained in the sql query.

    I tried many ways to do it, but with the help of County and the amount in the same query with a group clause is causing many questions... Any help is greatly appreciated.

    If I add the following section to the application after the statement of counting: over (partition by column) I - not a group expression error message.

    Thank you
    Rohan

    Published by: rbha4 on 11/03/2010 15:45

    Could you place everything in a view online and apply the analytical function in the outer query?

  • Re: What is the part number?

    Hello people...

    I was wondering what the part number is suppose to say? Does this affect the specification of your laptop to another? for example, I have this laptop [Satellite A300 - 1 G 5 | http://eu.computers.toshiba-europe.com/innovation/jsp/SUPPORTSECTION/discontinuedProductPage.do?service=EU&com.broadvis ion.session.new = Yes & PRODUCT_ID = 1055589]. As you can see from the link, the laptop displays a part number: PSAG4E-_ * 03801 MG 3 * _. On my laptop cover, the label of the model is identical to the first part, but different on the second, its written like this: PSAG4E-_ * 03801HAR * _, have you noticed the difference? How important is this difference?

    I'll explain why Im concerned about it once I get a clarification on what means the part number... Thank you

    Hello Poison

    AFAIK, part number is a kind of identification number. Each laptop model is available with several different hardware configurations and different hardware components.

    Your Satellite A300 has PSAG4E model number. MU by Satellite A300 has PSAG8E part number.
    When you visit the Toshiba download page, where you can choose model right after the part number. Drivers available for your PSAG4E probably won't be the same as for my PSAG8E.

    I don't know what the difference is, but maybe my laptop model has other graphics card, the sound card or the card wireless network may be. This part of the part number is important to you.
    Other numbers behind this first part of the part number is depending on the country and it is absolutely irrelevant for you.

    So, what's your concern?

  • Help explain the flow meter VI

    After a lot of tinkering, I seem to have developed an effective VI for use with a type/pelton turbine flowmeter. The flow meter outputs a stream of pulses which

    can count on the counter of my 6501 line. Unfortunately this eureka moment happened somewhat by chance, and I'm hoping someone

    could be kind enough to explain step by step or in terms very simple for beginners (me) works of VI, thank you.

    Kind regards

    GER

    GER,

    Welcome to the Forums and LabVIEW.

    If you don't the have already made, please work through the tutorials online to get started with LabVIEW. The answers to some of the questions you may have are probably there.

    A brief description of your VI:

    1. the overall structure is a loop For. It works for the number of iterations that is connected to the Terminal in your case 5 N.

    2. the calendar of the loop is determined by the longest time required for any part of the code inside the loop execution. On the first iteration, the DAQ Assistant configures the counter and starts measurement. On all subsequent iterations, he reads everything simply an indictment. On these iterations, the 25 les 25 ms ms expect will dominate. This VI runs approximately 40 iterations per second (for 5 iterations).

    This means that the program will take place on 5 * 25 ms = 0.125 sec and then stops. If you run for more 1/8 of a second to help run it continuously button, STOP. Which is intended for certain types of troubleshooting only.

    3. the table of waveform and the flow rate meter only shows the last value of the five iterations. (This suggests also that you use run continuously)

    4. the registers at offset in this VI nothing do. The upper shift register calculates the cumulative number of the flow meter, but the result is never used. The underpass registry has nothing connected to the Terminal inside the loop on the left. It could be replaced by a terminal.

    Suggestions:

    1. in order to avoid using run continuously, replace the loop with a while for loop. Add a stop button on the front panel and connect it to the stop it real terminal in the loop. Move the graphic terminals of waveform and flow inside the loop.

    2 check your pulse to the algorithm of flow rate. The time for the count interval must be considered.  For example if the meter registers 25 pulse in 25 Member States, which represents 1 000 pulses per second. This isn't which will show your VI.

    3. see examples of code that uses counters.

    Lynn

  • Monitoring of VPN - running Total

    Hello

    I was wondering what is the meaning of the Total cumulative number means?  I guess it's just the total amount of connection which took place up to this point and does not affect the total number of allowed simultaneous connections?

    Thank you.

    Hi Max,.

    The cumulative is simply a number of Ipsec firewall connections recorded since is online.  This has no effect on the number of counterparts Ipsec or VPN simultaneous connections the ASA can manage.  Cumulative are just statistical database on all of your SSL/VPN, etc... saved connections.

    These statistics can be eliminated by clear statistics of vpn-sessiondb in global configuration, or mode when the firewall is reloading.

    Kind regards

    Jorge

  • procedure for NUKING all THE e-mail settings

    I decided to nuke everything on my mac air associated with the settings of mail no matter how much I try, I can't him reliable get new messages. I have been kindly provided a number of different (and relatively technical) papers and decided to wear it just to the genius bar.

    would someone mind just doublechecking my methodology here before I go through setting up again? I do not have these articles printed here, but if I can do this without /studying/ upward on the mail (again) I would be excited.

    So basically what I did is I took at the genius bar and had the nuke guy all settings and we decided collectively I go home and remove and then reset the accounts.

    now I think I have it FIRST remove accounts and nuked THEN all of the data.

    am I right in thinking that I should go ahead and "re-nuke" all parameters before the definition of my new accounts?

    It occurred to me just now that I opened the mail at a coffee shop - I am connected to WIFI - and I have no mail. so now I am delete my email accounts, but I think the crab data will still be in the system after I delete the accounts and reset them to the top.

    thoughts?

    Thank you

    I don't see why it would be wrong to repeat what has been done on the Apple Store before adding back accounts. It helps ensure that you start with a 'clean slate' and not data withholding.

  • capture multiple and reading images

    Hi all

    I use a Guppy F031 Pro camera equipped with trigger mode in bulk.  Now I can leave the exposure of the device twice in the series after an external trigger (my previous post).  But I don't know where are the stored images and how to read the two outside pictures and store them in the hard disk.

    When I use IMAQdx get image vi to capture image and set as number mode with 2 buffer pads.

    Does this mean that I assigned two location in RAM for my image?  If so, how can I find their location?

    Best,

    Wen

    "When I use IMAQdx get image vi to capture image and set as number mode with 2 buffer pads.

    Does this mean that I assigned two location in RAM for my image?  If so, how can I find their location? »

    -To my knowledge, it is false.

    Buffer allocation:

    -There are two types of internal buffers and buffer of the user you want to set up and use.

    -internal buffer is that you can configure using IMAQdx configure acquisition and giving the required number of buffers you want to allocate.

    -the user buffer is a condigure you or create using IMAdx create and giving them different middle names, creating several buffers. (You must remove the user buffers when finished processing using IMAQdx has, otherwise it will fill the RAM memory.

    Number of buffer:

    -A number of buffer is a zero-based index that represents the cumulative number transferred image. For example, during an acquisition continues with three internal buffers, the number of buffers is updated as follows: 0, 1, 2, 3, 4, 5 and so on. Buffer 0 and 3 numbers correspond to the same internal buffer in the ring of the buffer. (From NI IMAQdx manual)

    -Which means you will need to give different buffers number each time adding 1 whenever you receive an image. and not a constant of 2.

    For your question:

    -Configure the acquisition with more than two buffers, start the acquisition.

    -Give the number of buffers to 0 and increment after successful image and send it to IMAQdx get image.

    -For each image, your user buffer is even currently, which means that it will overwrite the same. If you want them to be different, you can create several and use also.

  • Spectral histogram of adc output

    G ' Day all the

    I have a LabVIEW task that I'm confident should be dealt with before (several times). However, not for the life of find me a solution documented. It's displaying a range of possibilities of an ADC on a histogram channel (no, not the statistical flavor - the spectral version of science).

    I have a 8 k ADC front-end DAQ loop which (for reasons of this example) gives me the amplitude of incoming impulse (value between 0 and 8191). In this loop, I would a 'live' spectrum in real-time of the cumulative number of hits by way of the ADC.

    I can think of ways using an 8 k array and incrementing the bins manually but how to get the data in the table persistent in the loop... and actually display.

    If I have to invent my own wheel to solve this problem while it is OK, but I'm sure that like most of my brothers of coding, I'd rather use someone else

    See you soon
    Steve

    Look at this example of a histogram. Which is similar to what you need?

  • Rate counters/timers

    Hello

    I use the entrance of counter/timer on a map of 6040E for counting of events.

    I use CTR0 and have specified the clock 20 MHz as my source and connected my event at the door (PFI9). I has a finite number of impulses and I am configuration of the buffer using the DAmx Timing (example of clock) vi.

    My question concerns the entry of 'rate. ' Counter source is positioned at 20 MHz is not the rate? Can anyone advise as to how to choose a reasonable value and what effect it has.

    I usually use the rate for analog I/o buffers in order to fix the rate of buffer - I can't quite see its use in this case.

    Thank you

    I forgot to go to the part of rates, for counting of events, the rate is how many times buffering you your edge counter value.

    IE I count photons a PMT, I would like to see the cumulative number every 1ms so I plug the source on the PMT and run continious at 1 kHz, every second, I read 1000pts and plot.  I think that this is how the rate.  For measurements, the clock is implied, there is no price since the edges of ascnchronous determines the time to write to the buffer.

  • Use screws of no class within the class

    I guess that it is a theory of the question of the OBJECT-oriented programming.

    Say that I have 2 classes, 1 is used to adjust the tension on a diet and another is used to update a user interface.  They are not really related to all that there is no common parent class and there is essentially no relationship between them.

    Now I write a Subvi, which is a kind of random number generator specialist.  What happens if I want to use this VI in a method of each of the two classes above, I created.  Where this Subvi belongs?

    I see the following options, but I don't know who should be.  I'd really like to hear your suggestions because it was bugs me for some time:

    (1) create a method in each class that has the functionality of random number generator.  I don't like this idea because I'll be duplicating code.

    (2) simply choose store the VI as part of my project and does not include it in classes.  I don't like this, it's that if I decide to reuse my code/class in another project, I need copy screws that are not part of my class with her.

    (3) create a kind of "utility" class which should contain all these various screws and then use the methods of this class.  I could pass an object of that class of utilities in each class so I would have access to methods.  But this seems to be quite complicated.

    So that is the dilemma.  I wonder how you chose to resolve this problem.  Thank you!

    Create a library for reuse.  I recommend looking in the VI package manager.  You can create "packages" of code reuse and 'install' in each version of LabVIEW.  Then everyone can use them since they are in a nice place.

  • 'C' disk full

    G ' Day,.

    My 'C' drive is full.  I have uninstall things that I did not need and Defraged and done a clean disk.

    I just bought a new external 2 to hard drive.  I want to change the files on my full disk to the new.

    I paid $120 to Microsoft for support.

    When I had a problem, a technician was able to connect to my computer and fixed everything.

    $120 would allow me to have the same thing how do I clean my 'C' Drive?

    Also I have to have some kind of reference number after I paid for support.  I have no idea where to find it now.

    I would appreciate help please.

    Perry

    That's what you are looking for advice in the field of the computer:

    My 'C' drive is full.  I have uninstall things that I did not need and Defraged and done a clean disk

    I just bought a new external 2 to hard drive.  I want to change the files on my full disk to the new.

    According to your information, you have prepared your C: drive to move everything, including the operating system, for the larger disk of 2 t.

    I have only included my link to sanitize your C including TreeSize:, because your question is different from that, as I explained:

    In this link is how to clean your drive C:. but it's not where your question.

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-files/my-user-folder-shows-30gb-data-actual-data-is-only/232dadfb-04F9-4FBF-b235-01a2b1124947

  • No internet with SG300 and RV320

    Hello

    Kind of a number is double.

    I currently have a SG300 L3 mode and a RV320 router. My original thought was to have the L2 switch and have the handle RV320 routing, DHCP, and DNS. I was told by some of my colleagues that I should have the L3 switch manages the Routing and use the RV320 just at the gates of the internet with firewall/NAT. The problem I have now is, according to the Administrator's guide, the RV320 must be in gateway mode since it will be the device actually connected to the internet... Problem is that ping outside the internet does not work, DNS relay seems to work, but nothing else. How are the packages supposed to get out if the router has not a '. '. 1"address. In addition, one-to-one NAT and PAT is not enabled, is NAT works not at all?

    I put virtual local networks in place in the RV320 and roads seem to be there. What I am doing wrong? I'm about to give up and return to the L2 mode on the switch.

    Also, I had to give the DHCP responsibility towards the SG300 as the RV320 handed himself a default gateway '.» 60"and not the". " 1 "the SG300. What is the problem with that? I want to use RV320 as my DHCP/DNS box, but that seems to be easier said than done.

    SG300:

    VLAN104

    VLAN105

    192.168.4.1

    192.169.5.1

    RV320:

    VLAN104

    VLAN105

    192.168.5.60

    192.168.4.60

    I don't think its possible to do, but maybe cisco can ring if it is possible or not

Maybe you are looking for

  • RealPlayer low load has stopped working on June 13, 2013

    It worked perfectly two days ago. Now, I can't download anything with realplayer. Sometimes nothing happens when I click 'Download video', sometimes it is as it is downloading but at an accelerated speed, but when I try to read it all I have is a bla

  • Not able to see my attachment to iphone6s

    Hello everyone, need your support, I can't see my attachments in emails, please suggest a way out to resolve the issue please.

  • How to connect 2120 PSC to laptop?

  • Laptop HP 15-d003se: NOT of Wifi on Hp 15-d003se

    HELLO EVERYONE! Hoping someone can help me. So, the thing is that I do not have wifi on my Hp 15-d003se at the present time. I don't know what happened, all I remember, it was last week (May 21, 2016) when I'm trying to connect to my wifi cousin, the

  • Wireless network problem

    When I start my Dell laptop that is running Windows XP, it will not connect to wireless (Intel PROSet).  When I try to connect to my network, I get the message "another application is controlling the wireless card." If I disable the wireless computer