Problems with separation of the results in different lines. Group question?

Hi all!

I have a table that looks a bit like this:
Pallet          Status          Number          Time
A          MoveIn          48          11:11
A          Pick          -1          11:11
A          Pick          -1          11:12
A          Pick          -1          11:12
A          MoveOut     45          11:13
A          MoveIn          45          18:20
A          Pick          -1          18:23
A          Pick          -1          18:23
A          Pick          -1          18:23
A          Pick          -1          18:24
A          MoveOut     41          18:25
A          MoveIn          41          21:31
A          Pick          -1          21:55
.....
It's exploitation forest pallets that is moved to a station and then number of boxes is picked off the coast. (To make it more simple, I only show a palette in above example.)

I would like to introduce the result with one row for each time that the palette were at the station, as:
Pallet          Picked          Time
A          3          11:11
A          5          18:20
A          ....          .....
This means that the same palette can be showned on several lines, as happened to the station several times. I tried several different 'GROUP BY', but I can't get it to work.
For example, I tried to group by time, but this fails if a pallet is moved twice per hour or if the boxes are picket at different times (for example, first box picked 09:59, last box 10:01)

Anyone has a suggestion how to fix this problem?

Thanks in advance and greetings / Anders from Sweden

Hej, Anders,

Can you explain what defines a group?

Looks like you say that a group is a subset of a palette. If we organize all the lines for a palette in the order of time, a new group starts whenever we have a line where status = 'MoveIn. In other words, a group consists of a line with status = "MoveIn" and all the lines immediately after, in order by time, up to, but not including, the next row with status =-"MoveIn. Is this fair?

If so, you can use the function COUNT (or SUM) Analytics to see how many lines with status = "MoveIn" have already taken place, in order by time, like this:

WITH     got_grp          AS
(
     SELECT     pallet, status, time
     ,     COUNT ( CASE
                         WHEN  status = 'MoveIn'
                   THEN  1
                     END
                ) OVER ( PARTITION BY  pallet
                            ORDER BY          time
                    )           AS grp
     FROM    table_x
)
SELECT       pallet
,       COUNT ( CASE
                  WHEN  status = 'Pick'
                THEN  1
              END
            )          AS picked
,       MIN (time)          AS start_time
FROM       got_grp
GROUP BY  pallet
,            grp
ORDER BY  pallet
,            grp
;

If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

This assumes that the combination (palette, time) is unique. Your sample data includes:

Pallet          Status          Number          Time
A          MoveIn          48          11:11
A          Pick          -1          11:11

I suppose that you decide to simply not show the full time, and your data is really something like:

Pallet          Status          Number          Time
A          MoveIn          48          23-Sep-2011 11:11:01
A          Pick          -1          23-Sep-2011 11:11:08

Otherwise, how do you know if these two lines are in you the same group or not? You may need to add a break to the analytical ORDER BY clause. For example, if you say "ORDER BY time, * status *", then, if the above two lines really have exactly the same time, to the second, then one with status = "MoveIn" would be considered as prior to the line with status = 'Choose'. "

Tags: Database

Similar Questions

  • problem with update of the repository into account line

    Hello..

    I could not update the number of lines in the obiee administration tool while working online.
    I practice the document

    http://www.Oracle.com/technology/OBE/obe_bi/bi_ee_1013/bi_admin/biadmin.html

    I skipped the step
    and I tried following step

    Create a new measure

    right now I tried click on results.

    im getting error


    ODBC driver returned an error (SQLExecDirectW).

    Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. NQODBC SOL_STATE: HY000 nQSError: 10058 a general error has occurred. nQSError: Oracle 17001: 904 error code, message: ORA-00904: "T168 '. "" CHANNEL_ID ": invalid identifier in the OIC call OCIStmtExecute. nQSError: 17010 prepare the SQL statement failed. (HY000)
    SQL issued: SELECT time. "" Calendar year "saw_0"sales facts. " "" Amount sold "saw_1"sales facts. " "" Unit cost "OF SH ORDER BY saw_0 saw_2



    Thank you

    The error indicates, column "CHANNEL_ID" undetected in DB...

    Try to overlap the DB for this column

    Kind regards
    Rambeau

  • Want to Phoenix 860-010: problem with fonts and the noisy fan

    I have a new machine, just a day old, and I'm having a problem with fonts.  The file Explorer, Edge and other similar programs seem to go from a very readable font that lights up in half a second or less whenever I move down on the page in these applications.  Police that results is much more difficult for me to read because of the lightness that results. I have not met this problem before.  Frankly, I don't know the source of the problem.  Is it hardware (video card) or (Windows 10) operating system software?

    Hello @PhotoGene47,

    Thanks for the quick response!

    Have you tried to see the document that I mentioned in my previous post?  If you prefer to have the Board repaired, you can consider contacting the HP support by phone for additional options.  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

    I hope this helps.

    Please let me know if this information helps you solve the problem by marking this message as 'accept as Solution' , this will help others easily find the information they seek.  In addition, by clicking on the Thumbs up below is a great way to say thank you!

    Kind regards!

  • problem with Safari and the opening of sites

    problem with Safari and the opening of sites

    Please describe the problem in more detail?

    Try to reset the settings of Safari:

    1. open Safari

    2. click on the Safari menu at the top (to the right of the Apple logo)

    3. Select the Preferences/Privacy tab

    4. click on remove all data from the Web site

    5. close Safari.

    Remove cache Safari files:

    1. click on finder

    2. look for the menu GO to top

    3. click on GO and hold down the option key. This will show a user library folder.

    4. click library and find the Caches folder

    5. in the folder caches com.apple.Safari Ouvrezledossier

    6. move the Cache.db file Trash.

    This should solve the problem. If it does not help, try to disable the Safari extensions

    1. open Safari

    2. click on the Safari menu at the top (to the right of the Apple logo)

    3. Select Preferences

    4. find the Extensions tab

    5 disable all extensions of

    6. relaunch Safari

  • Having a problem with loading in the combustion chamber

    Hello

    I'm having a small problem I could use help with. I'm not really sure what's going on, but I'm having a problem with one of the pages of my site does not when you try to view the page in Firefox. But if I loaded this page in Safari or Chrome, it loads very well.

    Here is the URL of the page to take a look:
    Specific link removed by moderator display ~ J99 < sitename >.com/top-10/top...services/

    No idea why this might be happening or how to fix it? I don't know if it's just my computer, or if others have the same problem.

    Thanks in advance,

    Mike

    There's two of us have confirmed the page will load so I deleted the link to display as it could be construed as advertising.

    P.S. Note only forum content in the resolved threads is now indexed by search engines.

    (Last updated: February 14, 2015 08:45 CEST)

    Solved the locked thread now ~ J99

  • Using an IP191 monitor, have random horizontal stripes on the screen - have no problems with other browsers. also no problem with FF on the other PCs on the family

    Using an IP191 monitor, have random horizontal stripes on the screen - have no problems with other browsers. also no problem with FF on the other PCs on the family.

    These "streaks" seem to be the domain of the high frequency analysis; they can be eliminated by scrolling upwards or downwards.

    Hello, maybe it's a problem with hardware acceleration - try updating your graphic driver, or in case this does not solve the problem, or there is no new version available at the time, disable hardware acceleration in the firefox menu

    > options > advanced > General.

  • I have an older version of Firefox 3.6.6 I think I'm having a problem with one of the websites that I sign. Is it possible to upgrade to the latest version

    I have an older version of Firefox 3.6.6 I think I'm having a problem with one of the websites that I sign. Is it possible to upgrade to the latest version. Without losing all my favorites and the saved passwords?

    Yes, see this article:

    After:

  • Problem with Vista hit the Satellite X 200 - 20 s

    Sometimes during typing on vista, it will stutter and freeze. The time is very short. Is this a problem with vista or the laptop. The T7300 Core 2 Duo 2 ghz processor.

    Hello

    I have a Satellite Pro S200 and the same problem was with my camera. It s is not a hardware problem, it s more a driver related issue No. So, the best thing you can do is update your bios and keep your drivers up-to-date. Just check the download Drivers Toshiba site and make sure you have the latest drivers installed.

    I had resolved my stuttering (core2duo 2.33 Ghz, 2 GB RAM) by updating all drivers...

    That's all

    Good bye

  • a problem with one of the files in the TestStand\AdapterSupport\LabVIEW directory

    When looking at the module a LabVIEW VI called for TestStand, I get the following message:

    A problem with one of the files in the TestStand\AdapterSupport\LabVIEW directory.  Please reinstall or repair.

    I made the mistake of cleaning C: in my computer.  Clean the C:\National Instruments downloads

    Why would someone put bits of applications or modules, etc. in such a directory?

    I'm not too crazy about restoring 11FR in this folder.  It's just crazy!

    If anyone has encountered this before?  No "easy"? outside re - install TS...

    Side note: I do not touch anything in the \Program files. National Instruments\TestStand\AdapterSupport\LabVIEW

    What version of LabVIEW and TestStand do you use?

    In 2012, TestStand, this directory is mapped to:

    C:\Documents and Settings\All Users\Documents\National Instruments\TestStand 2012\AdapterSupport\LabVIEW

    Have you tried mass compiling the screws in this folder?

    I had to create a new 'TestStand - default values XX.llb"file, where XX is the last version of LabVIEW you use, but I have not seen this message before.

    Good luck

    PH

  • Problems with access to the web pages, email, video, etc. even when I have 4-5 bars.

    I installed a Dell Wireless 1505 low-profile carrier 1.2 antenna dim/insp in desktop. Its a PCIe wireless lan card. But since last Tuesday patches have been installed I had problems with access to the web pages, email, video, etc., even when I have 4-5 bars.  Someone at - it an idea of what's going on.

    Hi William e. Swann

    1. what web browser do you use?

    Method 1:

    You can read the following article and check.

    You may experience connectivity problems or performance issues when you connect a portable computer that is running Windows Vista or Windows 7 to a wireless access point

    Method 2:

    You can also read the following article.

    How to troubleshoot network connectivity problems in Internet Explorer

    Hope this information is useful.

  • Problem with shutdown on the start menu

    Original title: PROBLEM WITH SHUT DOWN IN STAT MENU

    I had a problem with closing down on the start menu in my dell Inspiron CORE i3 laptop with windows 7. When I right click on the command prompt, and the user has clicked run as administrator nothing came, and now I can't click on anything whatever in the menu tab start such as my documents, my computer and Control Panel. Please tell me how to solve this problem. for this reason I can't tab from the command prompt.

    Hello

     
    Thanks for the reply and happy to know that the problem has been resolved.
     
    If you have problems with Windows in the future, please do not hesitate to post in the Microsoft Community Forums and we will be happy to help you.
  • I had endless problems with Lightroom since the purchase of subscription for one year in December 2014. Now, the development Module was disabled, as they claim that my subscription has expired...  He spent more time to work does not, and I'm bitterly briv

    I had endless problems with Lightroom since the purchase of subscription for one year in December 2014. Now, the development Module was disabled, as they claim that my subscription has expired...  He spent more time to work does not, and I bitterly regret it.  Help, please!

    Open the Adobe Creative Cloud application then go to preferences then sign out and then sign back with the same Adobe ID that you used to purchase the subscription photographers, that is to say the same e-mail address and password.

    Then open Lightroom and go to the Help menu and make sure that it is signed in with that Adobe ID email address.

  • Anyone having problems with guides since the update?

    Anyone having problems with guides since the update?

    My guides are everywhere, since I updated my Illustrator last week. The guides are solid lines while they should be dotted (as defined in my preferences) when I'm zoomed out... and then disappear or become dotted but moved when I Zoom.

    It's so frustrating! I can't work like this!

    All the solutions out there?

    Thank you

    lyncylox,

    You can try to disable the GPU performance by clicking on the icon of the rocket in the bar of the App, or on the top of the menu bar, deselect the box Performance GPU; You may also uncheck performance GPU in your preferences.

    I think that the issue should be fixed with the 19.0.1 patch.

    Link to 19.0.1 release notes: https://helpx.adobe.com/illustrator/kb/illustrator-cc-2015-crash-bug-fixes-19-0-1.html

  • Problem with pdf for the opening of the health gov Web site.

    Problem with pdf for the opening of the health gov Web site. I use my ipad in Safari and have installed the application to adobreader. Healthcare gov support only suggested to disable the pop-up blocker. I did, and I couldn't always open the file. No problem on a desktop computer regardless of the browser.

    In my view, they spend on their web server to a document ECM server authentication. Someone else has the problem?

    I tried the Penguin, Chrome and Atomic browsers on the ipad and the same issue.

    Thank you!

    Keren

    Okay, actually, I think that there is a problem with the type of form. It is a form of a special kind (called a form XFA or Designer, for what it's worth), which can be opened with Adobe Reader and only on Mac or Windows. There is no iPad software that can read these.

  • Unique problem with selction on the table (Query Page)

    Unique problem with selction on the table (Query Page)

    I have a VO data Bulletin Board, with a transitional attribute for selction unique column.
    My requirement is that I need to identify the line that was selected in the table.

    I associated with fireAction singleSelection column, such that whenever the user selects the line
    I'm looking for that VO using some rowIterator.
    But when running the loop of the transient VO that is mapped to the singleSelection variable is the show as "n" / NUll
    for all the lines...

    So how do you identify the selected line in singleSelection to a table.

    -Sasi

    In the property inspector of the element for which you've put firePartialAction, you can find a property named "parameters". That mention primary key as your setting.

    You can get the arameter using pageContext.getparameter ();

    -Anand

Maybe you are looking for

  • How to remove the bar, for example "most visited" etc just below the URL address bar?

    Just below the location of the URL bar is a line of things that I don't want. It contains the most visited, to start, latest news, Apple. Mac, News, Yahoo!, Apple, welcome to Firefox. I want to reclaim that space and add it to the window, do not keep

  • I forgot my password for external HARD drive

    Hello Last year, I bought a USB HDD external 320. This external HARD drive is protected by a password. I have never changed the password, so the drive has the original password. I didn't use the disc about 6 months and now I put music in my iPod, but

  • Satellite Pro A40: MinPCI wireless network card required

    Hi all I would like to put a wireless PCI card in my laptop but don't have a clue what I'm looking for. Please could someone help me with suggestions, links, recommendations, information or anything that could help mesolve this problem Thank you

  • NOR-traditional DAQ will work with a USB-6008?

    Hi guys,. I have ordered a USB-6008 and I would use it with the NOR-DAQ traditional 7.4.4 instead of MX. Is this supported? Thank you Jim LV 8.6 LV 8.01 LV 7.1 TS 4.1

  • Battery draining fast with LTE/3.2.2 upgrade

    Hi all Just got my XOOM back updated a few days ago and I noticed that the battery life is much worse that it was before I threw it away. I mainly use my XOOM to read ebooks, so I almost always have airplane mode on. Before the upgrade, I could spend