Avatar of hraja77
hraja77

asked on 

sql query

Hi,

I have a table which logs all reboots of a till on our system;
I need a query to see on a particular day how many tills rebooted - problem is that some times a till may reboot 3 times in a day and record three records into my table but i only need to show this as one:

my table is called audit: columns are:

id
timestamp
tillname

thanks
H
Oracle DatabaseSQL

Avatar of undefined
Last Comment
Hamed Nasr
Avatar of rmandra
rmandra

select tillname, to_char(timestamp,'mm-dd-yyyy') as Reboot_Day, count(*)
from audit
group by tillname, to_char(timestamp,'mm-dd-yyyy')
Avatar of hraja77
hraja77

ASKER

hi,

on one day the till will reboot more than once but i only want to record the fact it rebooted once

thanks
H
ASKER CERTIFIED SOLUTION
Avatar of Ess Kay
Ess Kay
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Can you show a sample of your required output? The answer that rmandra gave looks OK to me. Do you want to show just the days that have reboots? Then it's just a distinct, something like this:

select distinct(to_char(timestamp,'mm-dd-yyyy'))
from audit;
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Try to select till_id  , max(reboot time) , and count(),  Grouping By till_id.
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo