Classify files in groups

Hello

I want to sort records in consecutive groups: I am looking for a SQL solution. Help, please!

Here are some rules (actually stored in a table), I want to apply:

FOR B1, TRANSLATE each 2 entries IN ONE GROUP (group names can be sequential for... e.g.g1/g2/g3...)

FOR B2, TRANSLATE each 3 entries IN a single GROUP

WITH test
     AS (SELECT 'B1' COL_1, 'p1' COL_2 FROM DUAL
         UNION ALL
         SELECT 'B1', 'p2' FROM DUAL
         UNION ALL
         SELECT 'B1', 'p3' FROM DUAL
         UNION ALL
         SELECT 'B1', 'p4' FROM DUAL
         UNION ALL
         SELECT 'B1', 'p5' FROM DUAL
         UNION ALL
         SELECT 'B1', 'p6' FROM DUAL
         UNION ALL
         SELECT 'B1', 'p7' FROM DUAL
         UNION ALL
         SELECT 'B1', 'p8' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p1' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p2' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p3' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p4' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p5' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p6' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p7' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p8' FROM DUAL
         UNION ALL
         SELECT 'B2', 'p9' FROM DUAL)
SELECT *
  FROM TEST;

Output:

B1 p1

P2 B1

P3 B1

P4 B1

B1 p5

B1 p6

P7 B1

P8 B1

B2 p1

B2 p2

P3 B2

B2 p4

B2 p5

B2 p6

B2 p7

B2 p8

B2 p9

Expected results:

B1 p1 g1

G1 p2 B1

B1 p3 g2

B1 p4 g2

B1 p5 g3

B1 p6 g3

B1 p7 g4

B1 p8 g4

B2 p1 g1

B2 g1 p2

B2 p3 g1

B2 g2 p4

B2 g2 p5

B2 g2 p6

B2 g3 p7

B2 g3 p8

B2 g3 p9

WITH

test AS

(SELECT COL_1 "B1", "p1" COL_2 DOUBLE UNION ALL

SELECT 'B1', 'p2' TO DOUBLE UNION ALL

SELECT "B1", "p3" OF DOUBLE UNION ALL

SELECT "B1", "p4" OF DOUBLE UNION ALL

SELECT "B1", "p5" OF DOUBLE UNION ALL

SELECT "B1", "p6" OF DOUBLE UNION ALL

SELECT "B1", "p7" OF DOUBLE UNION ALL

SELECT "B1", "p8" OF DOUBLE UNION ALL

SELECT "B2", "p1" OF DOUBLE UNION ALL

SELECT 'B2', 'p2' TO DOUBLE UNION ALL

SELECT "B2", "p3" OF DOUBLE UNION ALL

SELECT "B2", "p4" OF DOUBLE UNION ALL

SELECT "B2", "p5" OF DOUBLE UNION ALL

SELECT "B2", "p6" OF DOUBLE UNION ALL

SELECT "B2", "p7" OF DOUBLE UNION ALL

SELECT "B2", "p8" OF DOUBLE UNION ALL

SELECT "B2", "p9" FROM DUAL

)

SELECT col_1, col_2,

'g' || TO_CHAR (case when col_1 = 'B1'

then ceil (row_number () over (partition by order of col_1 col_2) / 2)

Where col_1 = "B2".

then ceil (row_number () over (partition by order of col_1 col_2) / 3)

end

) col_3

OF THE TEST

COL_1 COL_2 COL_3
B1 P1 G1
B1 P2 G1
B1 P3 G2
B1 P4 G2
B1 P5 G3
B1 P6 G3
B1 P7 G4
B1 P8 G4
B2 P1 G1
B2 P2 G1
B2 P3 G1
B2 P4 G2
B2 P5 G2
B2 P6 G2
B2 P7 G3
B2 P8 G3
B2 P9 G3

Concerning

Etbin

Post edited by: Etbin

Oops should have checked before posting

Tags: Database

Similar Questions

  • Unable to file non-group of Shutterstock in Illustrator .eps

    Hi, I have bought the work in the past to Shutterstock and managed to separate images in the past with Illustrator. Now, however, several files of Shutterstock are not afford to separate the work. I contacted Shutterstock and they are able to disassociate their work in Illustrator on their end? I have to reload Illustrator?

    I have Adobe Illustrator CC, I used the direct Selection on the group work tool and object > Ungroup is grayed out (it me does not separate).  I tried to see if there is a clipping mask for which I could get out, he does not exist. I looked if my layers panel is locked, it is not. Again, Shutterstock is able to separate the file .eps at their end.

    What could be the problem? Help.

    Thank you. ~ Martha

    You have linked the EPS file, didn't you open it.

    Maybe you dragged to the opened file.

    The safest way would be now in the file > open, and then select the EPS.

  • Dreamweaver CS3, window file (Panel group) came only?

    Maybe it's a minor problem, but it is very annoying for me since I'm used to using a particular provision. In any case, after restarting my computer and start Dreamweaver, I noticed my window of files (Group of panels) was not on the screen, while it is usually on the right side and attached next to the code/design view. So I went up to the window menu and put a check by "Files" and he opened my file window, but it is not attached, as if it was before! Instead it floats just above my code/design mode, and I don't like it.

    I looked and looked at others but I can't understand how it related. Can anyone here help me? Any help is greatly appreciated!

    edited to add - I have tried everything just drag and "reconnect" the such Panel indicated in the help, but it won't dock or paste anywhere.

    My apologies, I figured out how to fix it. I don't know why it happened first, but anyway... problem solved for now. I was able to anchor it after got rid of the css Panel and just have the files Panel to open, not expanded, then move it up until I saw the black outline.

  • Gallery of photos Windows-how do to delete many files in groups

    Photo Gallery of MS

    For some reason, I have a lot of duplicates on my photo gallery.  Is it possible to get rid of them by groups rather than remove it at once? and why is it happening?  Also, can you me the difference between the photo gallery and Live Photo Gallery?

    Change of Monster copy in windows live photo gallery,

    Click on the dark blue button,
    Select options in the menu,
    Go to the original tab,
    Change the setting to never send original documents in the trash, too, send the original documents in the trash after one day.
    24 hours later all duplicates will be sent to the trash, and all recent changes are retained and or pictures you have ever edited kept, will

    After he rid the extras, you can open wlpg and review if double or sometimes reanalyses appear always.

    Check the Recycle Bin after confirmation that they went from wlpg and empty the trash.

    Then, you can change the setting to a setting more accommodating, so you can give yourself more time to return to the original.

    If you have just the library, click the button for options.

  • Reading a file preferably grouped in the project

    Hello

    I'm looking for help in how I would be able to read the contents of a file preferably I gathered in my project. I managed to read/play a media file that is packaged, but somehow there is a problem with the content of a text file that has delivered. It could be the method that I use. Here is some info on the project:

    JDE: 4.7.0.41

    Structure of the project:

    prefreader (name of the project)

    data (folder where the preferences file is stored - pref_config.txt)

    IMG (folder where is stored the png)

    Media (folder where the media file is stored)

    PrefReader.java

    AppScreen.java

    code snippet:

    try {}
    FileConnection fconn = (FileConnection) Connector.open ("file:///data/pref_config.txt");
    If no exception is thrown, then the URI is valid, but the file may or may not exist.
    If (! fconn.exists ()) {}
    Add (new LabelField ("config file not found"));
    fconn. Create();  create the file if it doesn't exist
    }
    else {}
    Add (new LabelField ("config file found"));
    tell java.io.DataInputStream = fconn.openDataInputStream ();
    con_tuple = dis.readUTF ();
    Add (new LabelField ("Tuple Data =="+ con_tuple "));
    } / / else
    fconn. Close();
    }
    catch (IOException ioe) {}
    Add (new LabelField ("exception:" + ioe));
    }

    Most new LabelField are simple debugging purposes.

    I use the FileConnection class. However, I do not know how to reference a file in the project compared to a file on an SD card or the root directory! I tried several combinations, and nothing works. I get a net.rim.device.api.io.file.FileIOException: file system error.

    Kind regards

    Sean.

    You cannot use FileCOnnection to read a file that has been registered in your COD file.

    See the following article:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To _...

  • Bridge CS6 Mac XMP file Info group bug: can not copy / paste metadata

    The cmd keys / shortcuts does not work in btw xmp file info panel. in the xmp / iptc fields (e.g., cmd-c, cmd + v,...) of Adobe Bridge CS6 (Mac OS 10.6.8 and 10.7.3). You are not able to copy / paste information from one box to the other like the previous versions.

    This bug appears in the Info window of the file (open via alt + i) xmp in Bridge CS6 - if you change the information or metadata in the file info panel in Photoshop CS6 copy and paste from one field to another works.

    Shortcuts also work under Windows (tested on Vista).

    More than a month ago, I noticed this minor bug already in version beta of Photoshop CS6. I hope that this has been corrected in the official test version, but unfortunately it isn't. Although it is a minor bug, it is in my humble OPINION, a basic function and it would be very useful in my daily work - it's a shame, such a little thing does work with the application a bit boring.

    Well, you can always use the context menu to copy and paste.

    Frank

  • How can I put files into groups

    I load pictures from my camera, but they are all placed in the same file.  How do I separate them into different files?  I have over 1000 pictures in one file.  It is difficult to manage.  Any suggestions appreciated.

    Just make records to match with the content of the images it contains.  Example: For images that contain you, make a folder with your name and put these photos in it.  The organizer did a great job of sorting anyway you want.  Have you tried to use the Organizer in Photoshop?

  • Why Microsoft does not insist on the grouping of the files by date?

    It's infuriating.

    I do not combine my files, I list by name or date modified.  Today, when I accessed my file system using the Windows 7 library, my files are grouped in the "earlier this year" and "long ago" no matter what field is used to sort.

    WHY?  !!!!!!!

    Why someone at Microsoft decides they will be they will mess up how to do things (developed over the decades) to satisfy a personal sense of aesthetics?  Now I breath a gaping hole in the time I have this evening trying to work around this problem.

    The closest thing I could find on the web is http://www.sevenforums.com/general-discussion/206265-win-7-sort-date-issue-2011-files-folders-now-long-time-ago.html.  However, I don't see the following, described by the solution menu item:

    View-> Menu-> Group by None

    In fact, I've not "see a view-> Menu

    Thanks to anyone who can provide a solution to this bug.

    You can just click between two files and view / sort by... will all appear.

    You can also click on organize upper-left / layout and check menu bar for see...

  • Mass convert files

    For better or worse, I scan old slides as TIFF files.  In the Organizer, PE8, I do a quick marking and fix the date and time of all the slides (using the date stamped by the photo lab if nothing else).     Then I classify into three groups: throw, snapshots, favorite.

    I would like to convert all of the images 'snapshot' class in high quality JPEG format.  I will probably not change them, if I do it will be no more than the 'culture' and 'smart fix.

    Is there a way to convert an image to a new file format group, keep the file converted in the organizer and keep the tags and dates, that I entered in the Organizer?

    PE8 Editor "process multiple files ' seems to be the same as in PE4 PE5 - converted files are not saved in the Organizer.  So, we need to return to the organizer and "unmanaged files Add to Catalog.   It's awkward, but it records the dates and (if you meet the command prompt), tags. I wouldn't mind so much, but after all what you need to always go back and delete the originals and you lost the selection.  You must have a good memory or a label with a tag 'remove me' before you go into the editor.

    It is possible, but tedious.   I prefer something more of this automated workflow.  For example, within the organizer just replace the TIFF file with a JPEG image.  Save as a JPEG in a gem-set version of TIFF would be ideal - and could be followed by a group "flatten version together.

    Did I miss an option faster?

    Did I miss an option faster?

    Yes, the quickest option is: do nothing. Do not convert TIF to JPG. Problem solved.

    Seriously, I don't see a good reason on your return, why you want to convert TIF to JPG, as do causes a slight loss of quality when the JPG is saved, it is all the extra work of the fixation of the Organizer. You said you wanted high quality jpg, but leaving the photo as a TIF is a superior quality.

    I'm dead serious here. A change in your habits of thought eliminates the conversion of jpg files work and eliminates your need for re-jigger the Organizer once you have jpg. In addition, you can avoid a serious question... most people advise you to NEVER delete your originals. I am convinced that this change in ways of thinking gives you a better solution! Objectives are of better quality than jpg files that you create. Leaving hair in the works of the great organizer, you can change as required and necessary created jpg (as opposed to in the batch), by selecting the photos of interest in the Organizer, and then file-> export-> as new files. And, as I said, it's less work.

    Now, I could think of some sort of good reason to convert TIF to JPG, but you don't mention a...

  • Contacts - assign group on import

    When the Yahoo address book importing (exported as a CSV file) is it possible during import the corresponding field to assign the category (the label of Yahoo) as a group?

    The idea is to bring in a few thousand emails, who have 10 groups of different sizes.

    I know that I can a) affect the other field label or Notes and then later b) search maps for names of previous groups, c) select all and then d) create each group. I hope that I can eliminate these steps.

    You could probably do with some AppleScript, but otherwise I don't think.

    I think that the simplest solution would be to divide the file into groups and import each separately. When you import, they all appear in the last Smart import group. You can then create your new group and drag them all since the last import in the new group.

  • Contacts app - cannot add a group contact

    Contacts app needs a bit of love programmer.

    I am trying to create a new group of contacts (* no * a "Smart group").

    I created the (file-> new group) group.  Tried to created in the section of the sidebar and "on my Mac" iCloud Same behavior.

    I select "All Contacts" and enter a keyword to search for. If the contact is not in the Contacts, but is in the Mail, you * must * "Add to Contacts" entry allows you to drag the contact into a group.

    You * might * be able to do it once or twice, but soon the Contacts won't you allow to drag anything else in the new group you created.

    If you leave Contacts and re - open, you can add one or two people, and then it stops once to answer more trolling.

    All this experience?  Or a solution?

    Hi there, Mark Rushton!

    Contact groups can be quite practical, and I understand your message you are having a little trouble to create yours--you cannot drag contacts you want in the Group shortly after. I know it's important to be able to create these groups with all you need, and I have a few steps, we can try troubleshooting.

    1. Exit the Contacts App. Hold down the SHIFT key on your keyboard. While now Shift, re - open Contacts. Try to add to your group again.
    2. Restart your Mac. Click on the menu  Apple in the upper left of your screen, then select "Restart" in the menu dropdown. When the computer is back on, Contacts open and try to add to your group again.
    3. Test of a new user account. This will help determine if there is no data that could cause a conflict. Instructions on the configuration and test in a new user account can be found in the article from the link below.

      How to test a question in another account on your Mac.

    4. Try to create your group in Mode without failure. Use the following article to help get into Safe Mode. Even if the title is not specific to your question, it's still a big step to take. Safe mode runs checks on your system and prevent execution that might be the cause of some software conflicts.

      Try safe mode if your Mac does not end commissioning

    Have a great day!

  • Replacement for the Working Group to el Capitan Manager?

    I recently built new servers, intending using open directory.

    The equipment I use are the new mac mini servers, with two 1 TB drives and 16 GB of memory.

    Historically I have used Workgroup Manager for direct starting, deployment of the printer files, user groups and others.

    Is there a replacement for the Working Group Manager who no longer works with el capitan (10.11.3)?

    The replacement is the Manager of service profile. See the built-in help of server for instructions begin. This is beta-quality software, at best.

  • How to retrieve properties of TDMS files in VBScript?

    We try to focus on some variables of our capture program of Labview in our DIAdem evaluation tool - the length of the videos that we are capturing and the overlap between them.

    We kept them as properties associated with the PDM file, but I can't understand how to access in a script. Any advice?

    Hi PGribble,

    Save the properties to the file level, group level, or the level of the channel?  If you have saved the properties to the file level, you have loaded a single file in the DIAdem data portal, or you have loaded several files into the data portal?

    If you can see the property you want in the table property of the Data Portal, you can simply drag the name of this property in the Panel in your VBScript SCRIPT tiara-DIAdem will insert the code to read this property.

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • TDMS file creates several tabs data. You want to create only one.

    Hello NOR community,

    I am currently using the DAQ Assistant with my pots of chain record travel over a long time interval (see annex VI). I then use the vi "Write to a file as" to save the data in a file TDMS (see 'Write the file settings' photo attached for all the parameters chosen for the writing of the file). The file is written, however when I open the PDM file, the document creates a tab in Excel for every second of recorded data (please see attachment ""). It seems that the TDMS file is grouping all data every second, and then by creating a new group of data.

    How can I get the file to write all data on a single tab instead of creating multiple? I don't want to concatenate hundreds of tabs in a single great sheet.

    Thank you

    Chris

    You should not use the comment.  I just removed who and everything worked for me.

  • Series quick reading of the channel group properties

    Hi, can someone please advice what is the fastest way to extract about 400,000 files channel group properties? Currently I use DataFileLoadRed with only the Group of channels that interests me and channels stripped down to a single value by setting the no. intervals of 1 and SectionBegin / end of 1/2. Suggestions for improvements? PHEX

    An alternative would be to open all files with the following code.

    Option Explicit
    
    dim groupindex : groupIndex = 1 ' you can also use a groupname instead
    dim groupProperty : groupProperty = "description"
    
    ' include this in a loop over all your files
    dim filePath : filePath = "C:\temp\example.tdm"
    dim store : set store = navigator.ConnectDataStoreByParameter("TDM", ""& replace(filePath, "&", "&") & "")
    dim propVal : propVal = store.RootElements(1).Children(groupindex).Properties(groupProperty).Value
    MsgBox propVal
    

    The files are open and your properties are extracted. Potentailly datafinder approach should be more fast but if you don't get that market this may be a way out.

Maybe you are looking for

  • iMessage probs IOS 9.3.1

    Hello my ISP allows me to know that apple has problems with their server regarding activation iMessage. When I sent a message to them to activate, the activation fails immediately and I get a message on my screen: "error during activation. Can Apple,

  • HP 50 g: Bug in LASTARG after MOD and other orders of CASES

    I mind not to check if this has been reported before, because it is a bug, and duplicate bug reports should be published until HP fixed them in a new ROM for HP 50g. I use the command MOD (in RPN mode in any case), example: 10 ENTER 7 MOD gives the c

  • RAM can be added, or replaced on Iconia B3 - A30?

    Hi, is it possible to add or replace on Iconia B3 - A30? If so, how? Or, as the case to take to do?

  • Is it possible to restore deleted items?

    I created lock folder and then deleted by mistake, he's going to the basket, I dnt use shift del, not even found in the trash, tried the system restore, but tat for me, has not helped net downloaded software and tried to restore, I found those delete

  • you just bought a dvd, the hunger games, and it won't play.

    My laptop is a HP pavalion dv6 - 3227cl.  I just bought a Blue Ray disc of 'The Hunger Games'.  He will not play.  Smart Media software wants to look for an upgrade.  When update is downloaded and starts, I get a message that the software is already