|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I want to do a Group By "date". However, the time on the end of the stamp does not allow me to group days, as each time of the same day is unique. For example, I want to group everything on 06/02/2004 and ignore the time stamp appended at the end.
Man, I hope that makes sense. Anyway, thanks in advance for any help you can provide. |
|
#2
|
|||
|
|||
|
Hi,
what you need to do is omit the extention use trunc function (you can trunc to the day, month or year): select ... from ... group by trunc(dt,'mm'); Galit. |
|
#3
|
|||
|
|||
|
Thanks, I did not know of that function, but I can tell if it works or not because I am now getting the "Not a group by expression".
Any Ideas? SELECT "branch" as "Service", "FOLLOWUP_DTTM" FROM "THIS_TABLE" WHERE ( "FOLLOWUP_DTTM" BETWEEN '05/28/2004' AND '06/11/2004') GROUP BY TRUNC( "FOLLOWUP_DTTM", 'mm') Thanks again for any help! ![]() |
|
#4
|
|||
|
|||
|
You suppoese to use the same expression in the SELECT clause that you are using in the GROUP BY clause, furthurmore you cannot use table alias name in GROUP BY clause and you also need a group function expression in your SELECT clause in case if you are using more than one column.
I also think that you should use TO_CHAR function to fetch only days or month or year, Let's see the example: SELECT TO_CHAR(hiredate,'Mon'), sum(sal) FROM emp GROUP BY TO_CHAR(hiredate,'Mon') / |
|
#5
|
|||
|
|||
|
Maybe you search something like:
SELECT TO_CHAR(FOLLOW_DTTM,'mm/dd/yyyy') NO_TIME_STAMP, sum(branch) Service, COUNT(*) FROM YOUR_TABLE WHERE FOLLOW_DTTM BETWEEN TO_DATE('05/28/2004/','mm/dd/yyyy') AND TO_DATE('06/11/2004','mm/dd/yyyy') GROUP BY TO_CHAR(FOLLOW_DTTM,'mm/dd/yyyy') ORDER BY NO_TIME_STAMP |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Group By and time/date stamps |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|