Link to home
Start Free TrialLog in
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
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

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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;
Try to select till_id  , max(reboot time) , and count(),  Grouping By till_id.