Count only the iterations of duplicates? [SOLVED]

Using Oracle 9i 9.2.0.6.0.

This could be something simple that I am on, there are plenty of ways to find and count duplicates but I'm looking for a way to count only the number of iterations of a duplicate, it is and then group them if possible.

For example, suppose that you have
store   customer   product    date
  1          John          A         2008/05/01

  1          John          A         2008/05/01


  1          John          B         2008/05/01


  2          Bob           C         2008/05/01


  2          Bob           C         2008/05/01


  3          Mary          D         2008/05/01


  3          Mary          D         2008/05/01


  3          Mary          D         2008/05/01


  3          Joe            F         2008/05/01
So I don't want to go back to the following:
Store    Duplicates
  1               1
  2               1
  3               2
I want to only count how many duplicates beyond the first row for each store, where a duplicate has the same store, the customer and the product. Then
1 John A 2 Bob C, had one double, and Mary has 2.

I've tried so far to use analytical functions to subtract the first value of each partition before doing a count or make a number from each partition but niether seems to work by a group of store.

Published by: a little rabbit on September 18, 2008 13:03

You can find the number for each group and subtract one, as follows.

SQL> create table t ( store int, customer varchar2(10), product varchar2(1), d_ate date );

Table created.

SQL>
SQL> insert all
  2     into t values ( 1, 'John', 'A', date '2008-05-01' )
  3     into t values ( 1, 'John', 'A', date '2008-05-01' )
  4     into t values ( 1, 'John', 'B', date '2008-05-01' )
  5     into t values ( 2, 'Bob',  'C', date '2008-05-01' )
  6     into t values ( 2, 'Bob',  'C', date '2008-05-01' )
  7     into t values ( 3, 'Mary', 'D', date '2008-05-01' )
  8     into t values ( 3, 'Mary', 'D', date '2008-05-01' )
  9     into t values ( 3, 'Mary', 'D', date '2008-05-01' )
 10     into t values ( 3, 'Joe',  'F', date '2008-05-01' )
 11  select null
 12  from   dual;

9 rows created.

SQL>
SQL> select distinct
  2         store
  3  ,      cnt - 1 as duplicates
  4  from  (
  5         select store
  6         ,      customer
  7         ,      product
  8         ,      d_ate
  9         ,      count(*) over (partition by store, customer, product) as cnt
 10         from   t
 11        )
 12  where  cnt - 1 > 0;

     STORE DUPLICATES
---------- ----------
         2          1
         1          1
         3          2

Concerning

Tags: Database

Similar Questions

  • Query that count only the column null lines

    create table test
    (a varchar2 (10))
    b varchar2 (10),
    c varchar2 (10),
    d varchar2 (10),
    e varchar2 (10));


    SQL > DESC TEST
    Name Null? Type
    ------------------------------- -------- ----
    A VARCHAR2 (10)
    B VARCHAR2 (10)
    C VARCHAR2 (10)
    D VARCHAR2 (10)
    E VARCHAR2 (10)

    SQL > SELECT * FROM TEST;

    A B C D E
    ---------- ---------- ---------- ---------- ----------
    A1 - A3 A4-
    B1 - B3, B4-
    C1 - C3 C4-
    D1 - D4 D5
    -E2 - E4 E5


    I want an application that only count the rows of the column as null

    A B C D E
    --- ---- ----- ------ -------
    1 4 2 0 3

    Published by: Nilesh hole, Pune, India, on August 28, 2009 12:30
    select SUM(case when a is null then 1 else 0 end)
          ,SUM(case when b is null then 1 else 0 end)
          ,SUM(case when c is null then 1 else 0 end)
          ,SUM(case when d is null then 1 else 0 end)
          ,SUM(case when e is null then 1 else 0 end)
    from TEST
    /
    

    Published by: Toon Koppelaars August 28, 2009 09:07

  • Lightroom displays only the previews/thumbnails? (SOLVED)

    5.2 update (win7 x 64) all my collections show, but everything in the library is empty. Develop also shows just gray?

    Any ideas?

    Maxi

    SOLUTION: http://www.lightroomforums.net/showthread.php?14070-How-to-Assign-an-sRGB-ICC-profile-to-y our monitor % 28Windows % 29

    I chose my profile of calibrated monitors.

  • How can I count only text fields that have been used?

    Hello

    I use Livecycle Designer to a dynamic form.  I have a section of the form that contains the field for the user to enter the goals, and then note the purpose.  I want to count only the text fields with entries and have the total number of rates, divided by the number of entries in text field.

    Line 1, column 1 - goal is to collect 5 apples.   Line 1, column 2 - the given rate is 5

    Row 2, column 1 - goal is to collect 5 pears.  Line 1, column 2 - the given rate is 5

    Two goals for a total power of 10-10 divided by 2 = 5

    Is it possible to count only the fields that are populated?

    Also, is it possible to create an error message if the user scored 5 goals but rated only 4 of them?

    Please send me the form to

    [email protected]. I'll get it repaired for you and send it back and then you'll have the code in the form of sample for later reference.

  • When I launch Firefox, I get only the bottom of my browser in the Firefox window. I have already reinstalled it, but it does not solve the problem.

    When I launch Firefox, I get only the bottom of my browser in the Firefox window. I have the normal window for 1 second, but it changes in the background window only. So, without the toolbar or navigation. I have already reinstalled it, but it does not solve the problem.

    Hello jonson00, please follow the troubleshooting steps in Firefox opens with a white or transparent window. If this solves the problem, it would be also interesting including the extension has a problem in your case. Thank you!

  • How can I get my Teststand report to display only the data of the latest iteration of a loop DoWhile ONLY stage?

    Good so I a DoWhile loop with a numeric value to test.  The loop will run 10 times.  I want only the status of success/failure of the test of the numerical value of the last iteration of the loop is displayed in the report.  I don't like on the other iterations.  Help, please!  Thanks in advance I think that this can be accomplished with the recall of ModifyReportEntry and fancy logic...

    Thanks for your comments everyone.  I ended up changing the reportgen_txt.seq to identify during my test was in a loop (by setting an additional result in the different stages of my comment loop-step to say "Record last loop.".)  Once this indicator lies in the ResultList I turn to reportgen_txt, I have to loop through all the ResultList entries and if the current entry has the same name and the "record last of loop." as a previous entry, I delete the previous entry and store the current.  All this way, I have to do is to set a flag in my test sequence, and if when debugging, I want to see all the data for all the iterations, I just remove the flag.

    The reportgen_txt.seq include:

    C:\Program NIUninstaller Instruments\TestStand 2010\Components\Models\TestStandModels

    I'm not worried about the time constants on my generation of report and I am not limited to stress strict memory so this seemed like the best way for me to do what I had accomplished.  I'm sure there are better ways, but it seemed simpler than the generation of report definition to be disabled and then enabled...

  • repeating nodes using loop but when XML string concating then concating only last iteration of the loop FOr?

    I stuck with a problem that I use FOR loop to generate expandable nodes.
    Now when I concat the node generated in the primary node and then I only last iteration of the loop FOR.
    can someone suggest me a way to manage this error...
    BECAUSE me IN 1.pl_phone_tab. County
    LOOP
    SELECT xmlelement ("phone"
    , xmlelement ("PHONETYPE", xmlattributes ('01' AS "dmnADRP_PHONETYPE"), pl_phone_tab (i) .p_phtype_tab)
    , xmlelement ("PHONENUM", pl_phone_tab (i) .p_phnum_tab)
    , xmlelement ("PRIMARY_CONTACT", pl_phone_tab (i) .p_prcon_tab)
    )
    IN p_phone_xml
    DOUBLE; END LOOP;
    SELECT xmlelement ("PhoneInfo"
    xmlconcat (p_phone_xml))
    IN p_phone_info_xml
    DOUBLE;
    Here, I'm a single node, but there must be two nodes for node of PHONE
  • Hi, I need to download the acrobat PDF after registration and cc payment, I get the new which is not available for mac ist... How can I solve this problem... I use only the mac...

    Hi, I need to download the acrobat PDF after registration and cc payment, I get the new which is not available for mac ist... How can I solve this problem... I use only the mac...

    If you had bought subscription Acrobat Standard / stand-alone product , you need to cancel the subscription / order and re - register / re - order subscription Acrobat Pro DC / stand-alone product.

  • Ctrl-alt for double layer now duplicates groups not only the layer?

    I almost always duplicate the objects or layers by using ctrl-alt drag (while using move tool) to duplicate the layer.  Now, in the last Photoshop CC 2014 it duplicates the not only the layer group.  Is this a setting?  Thank you

    Well, obviously, in the December Update they fixed it... It must have been a glitch in the previous update.  So if you have this problem - update to December was last updated.

    Thank you

  • If I delete a song in the list of duplicates itunes, it has an effect on the existing playlist?

    If I delete a song in the list of duplicates itunes, it has an effect on the existing playlist?

    Official notice of Apple on the duplicates is here: find and remove duplicates in your iTunes library. This is a manual process and article fails to explain some of the potential pitfalls such as the lost coast and membership of playlist, or sometimes the same file can be represented by multiple entries in the library as well as a removal and recycling the file will break all the others.

    Use MAJ > view > show items to reproduce exactly to display the duplicates because it is normally a selection more useful. You must manually select all but one of each group to remove. Sort the list by Date added can make easier select appropriate tracks, but it works better when executed immediately after the dupes were created.  If you have several entries in iTunes connected to a same file on the disk hard then don't not send to trash.

    Use my DeDuper script (Windows only) If you are not sure, do not want to do it by hand, or want to maintain ratings, play counts and playlist membership. See this background thread , this post for detailed instructions and Please take note of the warning toback up your library before deduping.

    (If you don't see the menu bar press ALT to temporarily view or CTRL + B to keep displayed.)

    The latest version of the script can put away the dead links as long as there is at least a double live to merge his stats and membership of the playlist and must deal wisely when the same file has been added through multiple paths.

    With this many files, it might pay to break down the problem into smaller pieces.

    TT2

  • The rehabilitation of the iterations of the loop to 0

    I need help resetting my iterations of the loop back to 0.  Most of the time it works very well but has a bug.  Some background on what I'm trying to do.  Basically, I'm ordering a motor with a brake on the subject.  On the brake, there is a manual replacement option that I follow with a proximity sensor.  If the magnetic field is broken, it will stop the VI with the iteration, that he stopped.  When I press the Start button, the iteration continues. The VI stops when equal iterations # Set value witness of Cycles.  I tried the reset of the iteration option to 0 if I wanted at any time, so I put a reset button in the VI.  It works very well with the one bug. This bug is that if for some reason, the number of iterations is higher than the Set # the number of Cycles, the VI will continue to operate.  This is where I need help, because I don't know how to go about it other that pretend by setting the threshold min by a large number, forcing the operator to reset the counter.  Is attached to a peg of the area of the code.  Any help or suggestions are greatly appreciated.  Thank you!

    swins wrote:

    The LabView run VI put the button in a State of "rest" and does not run until I press the Start button.  Thanks for the reply.

    Many people write their programs as they come out of the main loop when the program is finished. Then they on the LabVIEW run button to run the application again. Worse still, they have no main loop and push the button of continuous running. Both are wrong and the latter much more.

    Sorry, I assumed you were doing that, but without seeing more code, I could only guess.

    Changing the equals or is more than one stage of debugging. What is the loop that you want continue to run or just the rest of your application? If the loop continues to run then the output of the speaker or is always false, which means that the output of equal to is never true.

    You put sensors on the exit of the tunnel connected to the Terminal to stop loop and register iterations to offset? Also to put sensors on the three terminals of equal to and activate execution of climax.

  • iterator master past RangeSize for detailing the iterator

    Hello


    I use two nested af:iterators to display the controls of production with their positions.

    The master af:iterator poster panelBoxes (production orders) from left to right and buttons detail views af:iterator (positions) inside these panelBoxes from top to bottom.


    our names are very long, so I've replaced it by MASTERVIEW and DETAILVIEW


    < af:iterator id = "iter1' var = 'MASTER' varStatus = 'i '.

    lines = ' #{bindings. " MASTERVIEW.rangeSize}.

    value = "#{bindings." MASTERVIEW.collectionModel}.

    Binding = "#{pageFlowScope.DrmaNavi.drmaIterator}" >

    < af:panelBox text = ' #{MASTER.» BmCode}"id ="pb1"type ="default ".

    ...

    < af:iterator id = "iter2' var = 'DETAIL' varStatus ="n ".

    value = "#{MASTER.» DETAILVIEW}.

    lines = ' #{bindings. " DETAILVIEW.rangeSize} ">"

    < af:commandButton id = "cbWaPos" blocking = 'true '.

    ...

    < / af:commandButton >

    < / af:iterator >

    < / af:panelBox >

    < / af:iterator >


    It works fine until we have a production order with more than 7 posts (10 posts is maximum).


    In the PageDef.xml the RangeSize of the master iterator is limited to 7 we use this application on a mobile device with a small touch screen.

    The RangeSize of the iterator of detail is limited to 10


    <!-maximum of 7 orders can be displayed on the screen of the Tablet - > 1024 x 600

    < iterator lie = "drmaMASTERVIEW."

    RangeSize = DataControl "7" = "ProductionDataCollectionAMDataControl."

    ID = "drmaMASTERVIEWIterator".

    ChangeEventPolicy = "ppr" / >

    < iterator lie = "drmaDETAILVIEW" RangeSize = "10".

    DataControl = "ProductionDataCollectionAMDataControl."

    ID = "drmaDETAILVIEWIterator".

    ChangeEventPolicy = "ppr" RowCountThreshold = "0" >


    My problem is:


    Although we have a RangeSize of 10 in the iterator of detail I get only 7 buttons even if the DETAILVIEW returns 10 rows. When I put the master RangeSize 8 I get 8 buttons in the iterator of detail but my panelBoxes leave the screen on the right side.


    someone at - it an idea to solve this problem? I use JDeveloper 11.1.1.6.


    Thank you

    Christoph



    Hello

    I suggest your iterator links RangeSize = 25 for example and adding the logic in the rows of af property: Iterator directly.

    for example

    Try and let us know the result.

    Concerning

  • Get NPES trying to create a line of the iterator of table on the loading of the page.


    Hi all

    I'm new to ADF and try to learn from its concepts. I've created a workflow with the train and using 7 jspx pages as the train stops. When I move from one stop to the next stop, the data are made to the database.

    My use case is, I want to fill an iterator of table on the loading of the page based on the data provided on the previous stop.

    I tried to use the code to find the iterator and create the line the view object in support Builder bean as well as file impl application module(call the executable action method) but every time I got the same null pointer exception.

    The code used for creating line iterator:

    BindingContext bindingContext = BindingContext.getCurrent ();
    BindingContainer DCBindingContainer = (DCBindingContainer) bindingContext.getCurrentBindingsEntry ();
    IdIterator DCIteratorBinding = bindingContainer.findIteratorBinding("iteratorName");

    ViewObject vo = idIterator.getViewObject ();

    Line rw = vo.createRow (); It is the line where I'm getting null pointer exception.

    Trace of the exception:

    at oracle.adf.model.bean.DCDataVO.initFKs(DCDataVO.java:621)

    at oracle.adf.model.bean.DCDataVO.createInstance(DCDataVO.java:592)

    at oracle.jbo.server.QueryCollection.createRowWithEntities(QueryCollection.java:1993)

    at oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(ViewRowSetImpl.java:2492)

    at oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(ViewRowSetImpl.java:2533)

    at oracle.jbo.server.ViewRowSetImpl.createRow(ViewRowSetImpl.java:2514)

    at oracle.jbo.server.ViewObjectImpl.createRow(ViewObjectImpl.java:11079)

    Please correct me if I'm wrong, but that's what I think I understand that, iterator links are not initialized correctly on appeal by Builder or application module impl of the file that I use.

    I will need to create a listener of phase of page for the task flow and and use the method afterPhase to call my method for line creation and insertion in the table iterator. ?

    But this approach causes the phase listner class to call for each workflow page I don't want I need to fill out the table only for a single page and not to other pages of six.

    Please help me in this problem by providing suggestions and pointers.

    My version of JDev is 11.1.1.6.

    Thanks in advance.

    ~ Abhishek

    Hi Ben,

    Thanks for your reply. But it did not solve my problem.

    To solve my problem, what I did is mentioned below:

    In my support for this page two, I create a listner beforePhase method and named her beforePhase displaying page jspx tag property.

    when the phaseId is RENDER_RESPONSE, so I call my method to set the extracted database of the values in the table iterator. and it updated the iterator with new values.

    Thank you all for your answers.

  • NoSquint resized correctly web pages, but the superior task bars are still too large - for example, I can only the beginning of the URL. How to fix?

    After that the last version of Firefox all amplified, I used the add-on of NoSquint (60%), which makes web pages now as they did before. However, if the two albums at the top of the screen are of normal size, the lower ones are too big. The bar that contains the URL on the left and a Google search on the right space, for example, to view only the first two letters of a URL (after the / /).

    How can I make these bars look the way they used to? Thank you.

    To adjust the font size for the user interface, you can use the extension of theme font & size changer .

    This solve your problems? Please report to us!

    Thank you.

  • When I click on an address, instead of the name of domain appearing in the url field, only the IP address appears. How can I get the real domain to pop?

    When I click on an address, instead of the name of domain appearing in the url field, only the IP address appears. How can I get the real domain to pop?

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance/themes).

    You can attach a screenshot?

    Use a type of compressed as PNG or JPG image to save the screenshot and make sure that you do not exceed the maximum file size (1 MB).

Maybe you are looking for

  • My Satellite touchpad does not work

    Hi all I bought my Toshiba satellite i5 on 2010-12-26. Unfortunately, he was arrested while working on 02/05/11.I went to the repair center and they checked my laptop and said hard drive has been corrupted.They took 12 days to fix my laptop. I got my

  • Equium A200-1V0 does not start after recovery

    Hi all I have Toshiba Equium A200-1V0. I wanted to restore Vista back to the factory settings and used the recovery disc - everything seems to go well, selected 'no' on the disc Add on to the end, as I don't seem to have one. When you restart the lap

  • Error code: 080070424 (cannot install updates)

    whenever I turn on my PC I get a window saying "windows cannot verify the update. When I do it manually, I get "error (s) Found: Code 80070424 Windows Update encountered an unknown error." I have followed all appropriate assistance, but it still does

  • HP Photosmart C4640: HP Photosmart

    How can I print 2 photos 5 x 7 on a sheet of paper 8 x 10? I want to print the same photo twice on a single sheet. I use the software that came with the printer and although it has a 2 each model sheet 5 x 7, you cannot print the same image. When I t

  • AutoPlay does not!

    The AutoPlay function does not work. He was, but just seems to have stopped. I tried to verify that the shellhwdetect service is running, AutoPlay is controlled as with all parameters by default... but nothing. Usb/cd player or what ever is visible a