Dates and times in a subquery with a group by

I have some data that I need to group to the Month, Day, Year, Hour and minute in a subquery. Then I need to summarize it to the Month and year in the parent query.
If I try to group by the field itself, it is not taking it down to hour and minutes - just the day, so I am losing records.
if I do a TO_char(visitdate, 'DD-MON-YY HH:MI AM') in the subquery, then the main query no longer sees it as a date, so cannot do my TO_CHAR(VISITDATE,'MON-YYYY') in the parent. I could parse out the pieces using string manipulation, but that seems rather silly.
Is there a way to keep as a date in my sub query and then convert to a string?
it looks a little like this, with some other fields that I have to max, sum ...
visit     provider     person     visitdate
1     2     1     12/20/2012 10:30
2     2     2     12/20/2012 10:30
3     2     5     12/20/2012 11:30
4     3     3     12/21/2012 11:30
5     3     4     12/21/2012 11:30
I need to boil this down to
provider     visitdate
2     12/20/2012 10:30
3     12/21/2012 11:30
2     12/20/2012 11:30
Then I use that in a subquery where I use just the month and year
TO_CHAR(VISITDATE,'MON-YYYY') AS APPT_MO_YR
right now if I do a group by visitdate on the subquery it returns
provider     visitdate
2     12/20/2012
3     12/21/2012
even if I do a group by to_date(visitdate, 'DD-MON-YY HH:MI AM')
it is still returning :
provider     visitdate
2     12/20/2012
3     12/21/2012

Hi,
Sorry, it's unclear what you want.
What is the output you want from the given sample data?
Do you want to see data from individual times, and then summaries for the entire month in the same result set? If so, you can use GROUP BY ROLLUP or GROUP BY GROUPING SETS. For example:
SELECT        provider
,        NVL ( TO_CHAR ( visit_date
                        , 'MM/DD/YYYY  HH24_MI'
            , TO_CHAR ( TRUNC (visit_date, 'MONTH')
                        , '   MM/YYYY "Total for month"'
            )           AS d
,        COUNT (*)             AS total_visits
FROM        sample_table
GROUP BY   provider
,        TRUNC (visit_date, 'MONTH')
,             ROLLUP (visit_date)
ORDER BY   provider
,        TRUNC (visit_date, 'MONTH')
,             visit_date
; Output:
` PROVIDER D                          TOTAL_VISITS
         2 12/20/2012  10_30                     2
         2 12/20/2012  11_30                     1
         2    12/2012 Total for month            3
         3 12/21/2012  11_30                     2
         3    12/2012 Total for month            2

Similar Messages

  • TS2755 iphone 4s - date and time is incorrect/trouble with imessages

    Had to go into settings and turn off automatic for date/time, it was a month behind and a few hours...whats up?

    Try a reset:
    Reset: Hold the Sleep/Wake and Home buttons and don’t let go until the screen goes dark and the Apple logo appears (no data will be lost)
    You can also try Reset Network Settings:
    Settings > Genera > Reset > Reset Network Settings
    (This will reset all settings. This will not delete any data.)
    Reset All Settings:
    Settings > Genera > Reset > Reset All Settings
    (This will reset all network settings. This will not delete any data.)

  • Cisco SPA525g2 Date and time Not Synced with the PBX server

    Hello,
    We have a couple of SPA525g2 phone connected and registered to our PBX server. We were able to configure 3 extensions on different lines of the phone. However, at times we were encountering issues with the other lines configured on the phone. There are times wherein 1  extension configured on the phone is having one way audio issue, but the other extensions configured on the same phone is working fine. and we have to reboot/reset the phone several times for all the extesions configured on the phone to work.
    Also, whenever we reset the phone, the date and time will be way way behind the current date and time, eventhough we have already set the correct date and time before we reset the phone.
    How can we resolve the one way audio issue on 1 or 2 extensions of the phone, while the other extensions configured to it is working fine?
    How can we make the phone sync the date and time with the PBx server?
    Any input and help regarding this issue is greatly appreciated...
    Btw, date and time  issue not sync with the PBX server is just happening on SPA525g2, we have other phones like SPA303, SPA504, and SPA232D/SPA302D. All other phones' date and time is in sync with the server even though we reset them except SPA525g2.
    Thank you very much,

    PeterMacSF,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

  • When I try to adjust the date and time of an event by selecting Photos from iPhoto, the year I enter is altered.

    I have images in iPhoto from an older digital camera which did not record the date and time.  In iPhoto, with an event selected, I have tried to adjust the date and time by choosing Photo.  When I adjust the date and check Modify original files, it makes the date much earlier--in centuries.  I now have an event from August 2003 (the date I entered) which reads June 2, 1251 under the event!  When I attempt to correct it, it goes back further in time.  What am I doing wrong?

    (I use iPhoto only to import from my iPhone; I organize all my images, including thousands of RAW files, in folders on a big external drive.)
    Why are you using iPhoto at all? use image capture or drag and drop the photos
    The problem is that the files I am copying are getting stripped of the EXIF metadata
    eliminating iPhoto from your work flow will eliminate one oppertunity to have this happen  For photos in iPhoto it is best to export them rather than drag an drop them - this assures your EXIF and IPTC data is correct and uptodate
    Why would I be able, over many years, to retain EXIF metadata in photos imported from an iPhone--then one day find that the same workflow strips such photos of EXIF data?
    Because exporting is the supported way to "export" photos - I never drag and drop photos out of iPhoto and I never use thrid party programs on the photos in the iPhoto library - try exporting as suggested above and see if that is the solution
    LN

  • Set Date and Time Automatically...doesn't

    We've noticed that the setting to automatically synchronize date and time to Apple's time server doesn't work if the system preference is 'locked'
    In other words, if the user that's logged in currently, isn't an admin user, then the machine doesn't set the date and time automatically.
    As soon as you unlock the system preference by clicking the padlock at the bottom, the date and time sync as they should.
    Anyone else noticed this?

    We do want the clock correct. The issue here is that the internal clocks drift - as I understand it, this is the one of the main reasons behind using a network time server.
    With the Date and time preferences set to 'Set date and time automatically', the but with the lock at the bottom corner locked- it's as though being locked is preventing the automatic date and time settings from updating.
    But the preference is checked on, and so the clock should be 'resetting' itself as necessary.
    To give an example- say the machine has been off for a while, and unplugged. This will cause the machine not to know what the Date and Time is. When the machine starts up, the preference should kick in, and the machine should 'Update date and time' automatically.
    But it doesn't. So long as that padlock is locked, even though the preference is checked on, the machine will not alter the date and time - until the padlock is unlocked.

  • I have a 4s Iphone and want to add a date and time stamp to photos taken on the regular camera installed on the phone.  Does this require a separate app?

    I have a 4s iphone and want to date and time stamp photos taken with the regular camera installed on the phone.  Does this require a separate app?

    For such to be visible, yes. Many such apps in the app store.

  • Problem with date and time preference

    hi there,
    i set my date and time and the time support yesterday and then i click the lock button to prevent further chance and last night i shut down my iMac, open it again in the morning the lock open back up and the timezone support change.
    i redo that again and restart my iMac the same thing happen. is this a problem with my software or everyone have this problem?
    any idea what should i do?
    thanks in advance
    regards AL

    Having the same problem, & am running Parallels (which I haven't used for some time) not boot camp. I tick the box labeled "Set time automatically" & lock the "click the lock to make changes". When I reboot, the Lock is unlocked and the "set time...." is unticked. Any ideas. Cheers.

  • Problem with date and time syncing itouch to macbook

    i have a problem with the date and time on ical when i sync my itouch4 w my macbookair. whatever i entered into my calendar in itouch will appear different in my ical( with a 6 hrs advance difference) and the alarm i set on my itouch in the calendar doesnt ring at the right time as set even though it is shown the time that i wanted.
    Both my macbook n itouch are set to the same time zone and i have checked this many many times n the time is the same on both machine. but i just dont understand why is there a time difference when synced and my alarm just dont sound at the time it was supposedly set. it rings hours later n showing a different time that it was set but in the parenthesis the right time that i had set it.
    One time my computer ran out of battery n went into sleep mode and when i open it again, the time n date setting was all off. which im surprised why it had gone off. So did this create the problem i have now with the date n time sync or something else?
    please help!!!!

    Having the same problem, & am running Parallels (which I haven't used for some time) not boot camp. I tick the box labeled "Set time automatically" & lock the "click the lock to make changes". When I reboot, the Lock is unlocked and the "set time...." is unticked. Any ideas. Cheers.

  • When I create a calendar, in iphoto 8, I had an information pane lower left corner with date and time of the picture. Can it possibly be that the iphoto developers forgot about that in iphoto 9? This was very helpful when placing images according to date.

    Today I updated to the latest iphoto version. The update itself went smooth and nice as one is used to from Apple. But when I wanted to finish my already started calendar, I have encountered two problems. The first is that I can't view the aperture library anymore directly from iphoto. Instead I have to open the iphtoto library in aperture but then my calendar isn't there. So now I have to copy images back and forth. No problem.
    However, the old iphoto had a small information area in the lower left corner which was very nice to place images on an exact date. This seems to be gone...?? Really? How am I supposed to sort images according to date and time when I have to back to the library view every time? That's not very convenient..Or am I missing something?
    Thanks for ANY help!
    Patrick

    The first is that I can't view the aperture library anymore directly from iphoto.
    THat is exceeding strange since iPhoto '08 could not open or share an Aperture library - that ability was first introduced in iPhoto '11 - with the latest version of iPhoto and or Aperture you can open the same library with either application - http://support.apple.com/kb/HT5043
    In the current version of iPhoto the photos are sorted by date in the film strip - I've not recently done a calendar so do not remember the specifics -
    LN

  • Please help , I have iPhone 4S and have updated to iso6, don't know if that has anything to do with the problem but I can't set the year on date and time to the correct year, it automatically goes to 2578 ? Plz help

    Subject:
    Please help , I have iPhone 4S and have updated to iso6, don't know if that has anything to do with the problem but I can't set the year on date and time to the correct year, it automatically goes to 2578 ? Plz help

    Settings>General>International.
    Set the calendar to "Gregorian". You have it set to Buddhist.

  • There is something wrong with the volumes buttons in my macbook pro, every time i pressed the one who raises the volume, it leads me to the screen where (i do not no what its called) the background is black with the date and time and a calculator.

    There is something wrong with the volumes buttons in my macbook pro, every time i pressed the one who raises the volume, it leads me to the screen where (i do not no what its called) the background is black with the date and time and a calculator. However, when i lower it, my safari tab goes out of the screen. What do you guys think i should do? I'm getting very nervous.

    hey HAbrakian!
    You may want to try using the information in this article to adjust the behavior of your function keys to see if that resolves the behavior:
    Mac OS X: How to change the behavior of function keys
    http://support.apple.com/kb/ht3399
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • HT201272 How do i see a list of the apps that have been downloaded and the dates and times and amounts?  Tried to follow the on-line thing but i want to compare what has been downloaded with my visa bill.  HELP!!

    How do i see a list of the apps that have been downloaded and the dates and times and amounts?  Tried to follow the on-line thing but i want to compare what has been downloaded with my visa bill.  HELP!!

    See this -> http://support.apple.com/kb/HT2727

  • My iMessage for my Macbook Air is not working. It says no delivered with a red ! next to it. I have tried serval different options on trying to get it to work to include logging out of iCloud and checking my date and time. I have done about everythin

    My iMessage for my Macbook Air is not working. I have updated everything. My system is running on OS X Yosemite Version 10.10. When I go to send a message, it says no delivered with a next to it. I have tried serval different options on trying to get it to work to include logging out of iCloud and checking my date and time and updating FlashPlayer. I have done about everything I can think of. Any help would be greatly appreciate!

    Why start a new and very similar thread to your other one which you have not responded to (have you read the replies?)
    I suggest that no response is made to this duplicate thread. 

  • Issue with Date and Time Picker on Windows 8.1 and Office 2013

    We are having a issue with the Developer tool in Excel called the Date and Time Picker which puts a calendar field into the spreadsheet where you can select a date from the calendar popup
    If we change this date field and then save and close and reopen it reverts back to the previous date before the change was made
    If we do the same process on a Windows 7 machine with Office 2013 it saves the changes we made to the Date and Time picker field

    Hi jdono2,
    I'm using Windows 8 and Office 2013,and I can't reproduce this issue.
    Please make sure you have already upgraded to the latest version of excel, try to reregister the MSCOMCT2.OCX.
    Also you can try to use another date picker add-in to test this issue.
    http://social.msdn.microsoft.com/Forums/office/en-US/36f83f24-cd76-4f8e-aa7b-5f166666e7d3/excel-2013-popup-calendar?forum=exceldev
    Wind Zhang
    TechNet Community Support

  • CRYSTAL REPORT GRAPH WITH DATE AND TIME

    Post Author: Dino Dentone
    CA Forum: Charts and Graphs
    Dear forum,
    I am developing a Visual Studio .net 2005 Windows Form,i have a sql table with 2 field:1) DATA (date and time)2) Temperatura (numeric)I have to make a line graph with numeric data axes.I have insert two parameters' to customize the filtering, so i can have a graph of the temperature between to date and time.If i choose two date's and time (parameters) like 20/04/2008 00:00:00 trought 20/05/2008 00:00:00 i have no problemBut if a choose a range minor of 1 day (some hours like from 15/05/2008 00:00:00 trought 15/05/2008 08:00:00) i have no graph.It sound like it don't use the time values?Thank's for the Help.

    There is some debugging info on the website. I've had problems getting the text to work. It was generally that I installed either the wrong 'version' of ImageMagick (the recommended one works for me--I'm running Vista x64 and one time installed the x64 version and it didn't work). I also installed Ghostscript to get the font list to work correctly. At one time I installed the x64 version of Ghostscript and it didn't work with the plug-in, either.
    I installed two items:
    ImageMagick: ImageMagick-6.4.9-3-Q16-windows-dll.exe
    Ghostscript: gs863w32.exe
    I don't know if it is necessary but I also added the fonts from
    ghostscript-fonts-std-8.11.tar.gz to the c:\Program Files (x86)\gs\fonts directory. Some, none, perhaps all, may already be installed just by installing ghostscript--it has been so long that I don't remember exactly. I do know that the contents of the gs fonts directory contains all the files in the .gz, I just don't remember if I put them there separately or as part of the gs install :)
    You need to make sure the font size is large enough. I usually use about 2-4% of height and export a single photo to make sure I see the text correctly.
    Tim does respond to email when he can so if you can't get it to work you can always drop him a line.

Maybe you are looking for