
//To average the time that all the items has been check out on Jan  2009

select avg(datediff(ckinDateTime,ckoutDateTime)) from transactionsallID where id between 29391189 and 30356162;


// How to find it?
// same index on Vislab server?
select id, ckinDateTime from spl.transactions where year(ckinDateTime)=2009 
order by ckinDateTime limit 10;

select id, ckinDateTime from spl.transactions where year(ckinDateTime)=2009 and month(ckinDateTime)=1
order by ckinDateTime  desc limit 10;


// how to find the first and last transaction number of a day:

// first
select id,ckinDateTime from transactionsallID where date(ckinDateTime)='2009-01-25' 
order by ckinDateTime limit 1;

// last
select id,ckinDateTime from transactionsallID where date(ckinDateTime)='2009-01-25' 
order by ckinDateTime desc limit 1;





// To check the title of transaction number  10 000 000:

select title from transactionsallID where id=10000000;

// To count the number of dewey items on the 700 category on the first
//1000 transactions:

select count(*) from transactionsallID where (id between 1 and 1000) and (deweyClass like '7%');