Group by and count in every 5 minutes

Dear guy,

I need to recover table data transaction report for the number of transactions sumarizing and the sum of the value in every 5 minutes. Please look below

Last timeTypeValue
--------------------
12:01:12buy10
12:02:34pay a20
12:04:43topup10
12:05:55pay a30
12:08:34buy40
12:11:21buy40
12:12:46topup5
12:15:50pay a30
12:16:23pay a25
12:19:40pay a15
12:19:50buy15
12:19:59buy5

-get the number of buy and pay a transaction every 5 minutes and the sum of the value

the result of the will:

Last timetransactionnumber of value
--------------------         -----
12:00-12:05pay a1 20
12:00-12:05buy1 10
12:05 to 12:10pay a130
12:05 to 12:10buy140
12:10-12:15pay a00
12:10-12:15buy00
12:15-12:20pay a3 70
12:15-12:20buy2 20

Do you have ideas for this?

So thank you and enjoy

Ch

WITH DATA (last time, TYPE, VALUE)

AS (SELECT to_date('12:01:12','hh24:mi:ss'), 'buy', 10 double UNION ALL)

SELECT to_date('12:02:34','hh24:mi:ss'), "billpay", 20 FROM dual UNION ALL

Select to_date('12:04:43','hh24:mi:ss'), 'charging', 10 double UNION ALL

SELECT to_date('12:05:55','hh24:mi:ss'), pay 'a', 30 double UNION ALL

Select to_date('12:08:34','hh24:mi:ss'), 'buy', 40 double UNION ALL

SELECT to_date('12:11:21','hh24:mi:ss'), 'buy', 40 double UNION ALL

Select to_date('12:12:46','hh24:mi:ss'), 'charging', 5 double UNION ALL

SELECT to_date('12:15:50','hh24:mi:ss'), pay 'a', 30 double UNION ALL

SELECT to_date('12:16:23','hh24:mi:ss'), "billpay", 25 FROM dual UNION ALL

Select to_date('12:19:40','hh24:mi:ss'), pay 'a', 15 double UNION ALL

SELECT to_date('12:19:50','hh24:mi:ss'), 'buy', 15 double UNION ALL

SELECT to_date('12:19:59','hh24:mi:ss'), 'buy', 5 FROM dual)

-1/1440 is a minute so 5 / 1440 would be 5 minutes

To_char (SELECT trunc (SYSDATE) + (PIECE * (5 / 1440)), "HH24")

TO_CHAR (trunc (SYSDATE) + ((CHUNK + 1) * (5 / 1440)), "HH24")

TYPE

value

OF (-piece is the number of periods of 5 minutes since midnight)

Floor (to_number (to_char(lasttime,'SSSSS')) SELECT / 300) AS CHUNK

TYPE

value of MySQL

FROM THE DATA

GROUP BY floor (to_number (to_char (last time, 'SSSSS')) / 300)

TYPE)

/

HTH

Tags: Database

Similar Questions

  • Group by and count on the same table

    Hello

    DB version: 11.2.0.3

    Tried to SQL:

    create table log1 (identification number, status varchar2 (15) date of insert1);

    insert into log1 values (1, 'SUCCESS', sysdate-1);

    insert into log1 values (2, 'SUCCESS', sysdate-2);

    insert into log1 values (3, 'FAIL', sysdate-1);

    insert into log1 values (4, 'FAIL', sysdate-2);

    insert into log1 values (5, 'FAIL', sysdate-1);

    insert into log1 values (6, 'ERROR', sysdate-1);

    insert into log1 values (7, 'ERROR', sysdate-1);

    insert into log1 values (8, 'ERROR', sysdate-1);

    insert into log1 values (9, 'ERROR', sysdate-1);

    WITH AS TBL1

    (SELECT THE STATE OF 'SUCCESS' OF THE DUAL UNION ALL

    SELECT "FAIL" STATUS OF THE DUAL UNION ALL

    SELECT 'PENDING' STATUS OF DOUBLE)

    SELECT NVL (TBL1. STATUS OF STATE, 'TOTAL'), COUNT (LOG1.ID)

    FROM TBL1 JOIN LOG1 FULL EXTERNAL

    ON LOG1. STATUS = TBL1. STATUS

    GROUP BY ROLLUP (TBL1. STATUS)

    STATUSCOUNT (LOG1.ID)
    IN CASE OF FAILURE3
    SUCCESS2
    PENDING0
    TOTAL (*)4
    TOTAL9

    t need only State of SUCCESS, FAILURE, WAITING. and NUMBER of global ID omit the rest of type status as ERROR, etc. EXECUTION in the result set.

    I don't need the TOTAL (*) of the above result set. Which is total (Error).

    Please tell us how the query above can be changed to produce the result to wait.

    Thank you

    Hello

    So, you want to see all the tbl1 lines, if they have a match in log1, and for the grand total of lines, you must count the log1 lines if they have a match with tbl1.  This looks like a job for a FULL OUTER JOIN:

    SELECT t.status

    EARL of (l.status) AS cnt

    OF log1 l

    FULL OUTER JOIN tbl1 t WE t.status = l.status

    GROUP OF ROLLUP (t.status)

    HAVING t.status IS NOT NULL

    OR of a GROUP (t.status) = 1

    ;

  • My PowerMac boots almost every ten minutes in stand-by mood?

    I have a Power Mac (mid-2012) with driver OS X El Capitan version 10.11.4. In stand by mode the computer starts and stops almost every ten minutes. Have tried to locate the problem by restarting in safe mode and went through Control Panel without having to find the problem.

    My question: is this a problem known compared to OS X El Capitan, or is there something else the cause? And anyone know please how to fix this? Thanks in advance!

    These must be run as administrator. If you have only one user account, you are the administrator.

    Please launch the Console application in one of the following ways:

    ☞ Enter the first letters of his name in a Spotlight search. Select from the results (it should be at the top).

    ☞ In the Finder, select go utilities ▹ of menu bar or press the combination of keys shift-command-U. The application is in the folder that opens.

    ☞ Open LaunchPad and start typing the name.

    In the Console window, select

    DIAGNOSIS AND diagnostic USE information reports ▹ System

    (not diagnose them and use Messages) in the list of logs on the left. If you don't see this list, select

    List of newspapers seen ▹ display

    in the menu bar.

    There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points downwards. You will see a list of reports. A report of panic has a name that begins with "Kernel" and ends with ".panic." Select the most recent. The content of the report is displayed at right. Allows you to copy and paste to validate all of the content, text, not a screenshot.

    If you don't see any report, but you know, there was a panic, you have chosen diagnostic and using the list of Log Messages. INFORMATION on the USE of DIAGNOSTIC AND choose instead.

    In the interest of privacy, I suggest that, before posting, you change the UUID ' anonymous, ' a long string of letters, numbers and dashes in the header of the report, if it is present (it cannot be). "

    Please do not post other types of diagnostic report.

    I know that the report is long, perhaps several hundred lines. Please report all this anyway.

    When you post the report, an error message may appear on the web page: "you have included content in your post that is not allowed", or "the message contains invalid characters." It's a bug in the forum software. Thanks for posting the text on Pastebin, then post here a link to the page you created.

    If you have an account on Pastebin, please do not select private in exposure menu to paste on the page, because no one else that you will be able to see it.

  • Satellite L650-1GF - cooling fan runs every 3 minutes

    Last week, I bought a Satellite L650-1GF. Everything is fine except the noise from the cooling fan. Especially because it works almost every minute to cool the carrots. There is an annoying sound hum which takes about 10 seconds and is repeated every 3 minutes approximately.

    I checked with "Speedfan". The temperature of the hearts is fluctuating between 32 and 37 C. And at about 37 ° C, the fan speed to cool the computer.

    Two questions:
    1 is this normal that the cooling fan starts cooling to 37 ° c.
    2. is the annoying noise of the fan normal for this model of Toshiba?

    And what is acceptable, can I find examples to compare with what I feel here somewhere? I saw a lot of cell phones so far, but none of the cooling fans made a buzzing sound like this.

    Kind regards

    Jaco
    Holland

    Hello

    Have you ever tried to change the method of maximum Performance to optimised battery cooling?

    You can do this in Windows power management, but make sure you do this for the current profile of the power.

    Check this box!

  • Need to view daq reads per second but only to record a reading every 10 minutes. I would also like to record the date and time, at the same pace. Need help

    Need to show daq reads per second, but only to record a reading every 10 minutes, need help

    You are also looking to taste to 1 Hz data acquisition?

    My approach would be to use the DAQ acquisition to time your loop display reading each acquisition, then use the loop counter to control the logic of your writing to file.  For 1 Hz and 10 minutes write I would use 'quotient and remainder' I / 600; If rest = 0, then write the data point.

    For the date and time, under Calendar palette use the time get in seconds food a DateTime Format to a string.

  • Regenerate the Datastore groups every two minutes

    Hi all

    Currently, I have added a NFS data store on my ESXI hosts and now every two minutes I see regenerate the Datastore groups every two minutes. My VMKernel is set on a group of ports DvSwitch and MTU 9000. The Load Balancing Teaming and failover strategy he set for road base on physical NIC load. No idea why this happens or if this happen to someone can point me to the right direction.

    Thanks for any help!

    OK, I made myself. This problem was linked with the MTU not set correctly on the DvSwitch himself. Once I changed the Maximum MTU on Advaced Options, he stopped.

  • Receive the same email every 2 minutes... over and over again! How do we stop it?

    I received an email about an hour ago, and it is constantly through every 2 minutes. I opened a session on the system of e-mail and online deleted the original e-mail and all of the following conditions, but it is always through. Any ideas?

    He finally stopped when I managed to get the sender to delete the email system. Phew!

  • When Firefox in reduced and I work with another program, why does automatically optimize (pop-up) every 10 minutes?

    I use Windows 7 and 8.0.1 Firefox on a PC. It's frustrating. I like Firefox, but it keeps popping up every 10 minutes when it is minimized and I work in another program. I can't continue to use if it cannot be repaired. I just changed from 3.6 and never had any problems. In addition, no settings have been changed.

    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) > Add-ons > appearance/themes).

  • Problem with gel and hour glass lights as if the update every 10 minutes or so and lasts 52 seconds or more.

    When I'm on a site, any site or writing an email every 10 minutes or so, the hourglass comes on and I can't do anything other than wait. I think it's something to update. How can I stop this?

    Upgrade to Firefox 8.0 can do, unless there is damage to the indices places.sqlite, anyway, that's the cue and I actually (identical to the options) option.

    gel at regular intervals: http://blog.bonardo.net/2011/09/30/is-your-firefor-freezing-at-regular-intervals

    https://addons.Mozilla.org/firefox/addon/places-maintenance/

    Install the module, run at least the option mentioned in the article, I ran all. When finished, you can uninstall the extension, without having taken Firefox down, the extension is one of the new JetPack extensions.

    Thought I had this problem right now, but it's my anti-virus, usually binds things pretty well.

  • Firefox NEVER crashed. 7 Firefox hangs and crashes every five minutes

    I switched to FF a few years ago and never had a wonderful program of the problem. FF wanted to spend to the V7, and very comfortable. Since then, FF lock up every five minutes so bad, that I have to restart. My email locked, yahoo freezes and I can't type more than 5 letters in a conversation without blocking. Somehow, your boring help section trying this blame on other programs!


  • I have a second hand I pad problem is Ir won't let me pass the authorization page and maintains have turned off every 2 minutes, anyone has any suggestions please

    I have a second hnd I pad that won't let me pass the authorising officer page and although his full load it continues to go off after every 2 minutes

    Help, please

    Thank you

    Do you mean that you need Apple ID from the previous owner to enter the iPad?

    If so, bring her back. There is no way to get around that. It is called locking activation and is not something that a user can bypass

  • Every few minutes, I get a message "not responding" and I can't do anything until he goes.

    Every few minutes (sometimes in less than 60 seconds, Firefox crashes upward. If I try to keep typing I have a message "do not answer" and will have to wait until he's going to continue. This always occurs when you browse through my e-mail, but it happens to other sites, whenever I have to type an entry. I have tried disabling all my modules and it still happens. I deleted Firefox and reloaded it and the problem persists. I'm about to go back to Microsoft Explorer, because it is too long to navigate in Firefox. I use Windows 7, 64 bit, on a one-year-old Dell with a lot of speed, laptop memory and hard disk space.

    See Firefox crashes

    Also, try running Firefox in questions to troubleshoot Firefox in Safe Mode. If it works properly in this configuration, then one of your modules is the culprit.

    I also notice a couple of old installations plugin in your system specs. I recommend you to update Flash on v10.2.159.1 which also addresses a recently discovered Zero Day exploit. See Adobe releases Flash Player security update
    Update via http://get.adobe.com/flashplayer/

    Also, go to the Windows Control Panel. Java and updated for v1.6.0_24 by clicking on 'Update Now' button.

    You have AVG Safe Search, AVG Linkscanner or McAfee Secure Search installed? All three are problematic and tend to cause Firefox to slow down. They can be disabled in tools | Add - ons | Extensions.

    If the problem persists despite the above measures, please let us know and we will try to help you further.

  • Satellite P300 - 20 H refresh the screen every 10 minutes and turn off during 3 sec

    Hey,.

    Basically, I bought my P300 Sat about a month previously and each time it runs, battery, the same error will occur...
    It will update the screen every 10 minutes or more and turn off for 2-3 seconds.

    This isn't a big problem, but it is annoying that I can not sort.
    I tried to run a check of problem to find a solution, but he says that he can not find a.

    Help, please
    Thank you.

    Hello!

    Can you please explain what you mean with refresh? And what exactly is happening?

    It is not easy to say what the reason is for this, but have tested an external monitor on the laptop? And you can determine if it s a problem with the internal display or not.

    In addition, you must make sure that you have installed the latest display driver and BIOS. The two you can find on the Toshiba site:
    http://EU.computers.Toshiba-Europe.com-online decision-making supported Downloads & => Download drivers

    If you installed a display driver Toshiba not you should remove it. These display drivers can often cause problems and don t have protection against overheating.

    Good bye

  • Internet keeps disconnect and reconnect every 3 minutes

    Original title: network programs network networking Internet Web site Site Web Web Site URL

    Internet keeps disconnect and reconnect every 3 minutes approximately. I changed the computer so its near the door (the router is in the room) but I never had this problem with my laptop.

    Hello

    1. which version of the Windows operating system is installed on the computer?

    2 did you a recent software or changes to the material on the computer?

    You can go through the steps mentioned in the link and the Coachman.

    http://Windows.Microsoft.com/en-us/Windows/help/wired-and-wireless-network-connection-problems-in-Windows

  • I have the same problem. whenever I start windows it tells me it is install and configure updates, after 20 minutes he finally - but next time I start exactly the same thing happens - that is every day and im tired of it.

    I have the same problem. whenever I boot windows vista it tells me it is install and configure updates, after 20 minutes he finally - but next time I start exactly the same thing happens - that is every day and im tired of it.

    Hi MartinWithWindowsIssues,

    Welcome to the Microsoft Vista answers Forum!

    I have some steps that may help you.

    Step 1

    Try resetting the component of windows update.

    To do this, click resolve this present in the link below. Click run in the file download dialog box and follow the steps described in the fix it Wizard.

    How to reset the Windows Update components?

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

    Step 2

    Perform a scan of the file system [SFC] checker on the computer that will replace missing or corrupt files.

    To do this, follow the steps below:

    1. click on the Start button

    2. on the Start Menu, click all programs followed by accessories

    3. in the menu accessories, right-click on command line option

    4. in the drop-down menu that appears, click the "Run as Administrator" option

    5. If you have the User Account Control (UAC) enabled, you will be asked permission before the opening of the command line. You simply press the button continue if you are the administrator or insert password etc.

    6. in the command prompt window, type: sfc/scannow then press enter

    7. a message is displayed to indicate that "the analysis of the system will start.

    8. be patient because the analysis may take some time

    9. If all the files need replace SFC will replace them. You may be asked to insert your Vista DVD for this process to continue

    10. If all goes although you should, after the analysis, see the following message "Windows resource protection not found any breach of integrity.

    11. once the scan is finished, close the command prompt window, restart the computer and check.

    For more information, see the link below:

    How to repair the operating system and how to restore the configuration of the operating system to an earlier point in time in Windows Vista

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

    Hope the helps of information. Please post back and we do know.

    Joel S
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

Maybe you are looking for