I have few columns which are time and method etc. I need to display the operations performed on a day.
time,method
01-Sep-2022,1
01-Sep-2022,2
01-Sep-2022,2
01-Sep-2022,3
01-Sep-2022,3
01-Sep-2022,3
02-Sep-2022,1
03-Sep-2022,1
04-Sep-2022,1
Output
time,method
01-Sep-2022,1,1
01-Sep-2022,2,2
01-Sep-2022,3,3
02-Sep-2022,1,1
03-Sep-2022,1,1
04-Sep-2022,1,1
How to write the Oracle query ?
Oracle does not have a
DATETIMEdata-type; it only hasDATEandTIMESTAMPand both always contain a time component (even if the user interface you are using may choose to only display the date component, it still always has a time component).To group by the date component, use the
TRUNCfunction to truncate the time component back to midnight so that all values on the same day have the same truncated time:Which, for the sample data:
Outputs:
fiddle