==================================================================================================================================================================
CHECKOUT DURATION QUERY (no filter)
==================================================================================================================================================================
SELECT
	AVG(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS meanDuration,
	STD(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS stdDuration,
	MAX(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS maxDuration,
	MIN(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS minDuration
FROM
    spl2.inraw
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
19725742.7907	144225305.6927	1388935800	60
==================================================================================================================================================================
CHECKOUT DURATION QUERY (filter delinquent items)
==================================================================================================================================================================
SELECT
	AVG(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS meanDuration,
	STD(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS stdDuration,
	MAX(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS maxDuration,
	MIN(UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout)) AS minDuration
FROM
    spl2.inraw
WHERE
	( UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout) ) > 0
AND
	( UNIX_TIMESTAMP(cin) - UNIX_TIMESTAMP(cout) ) < 7776000;
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1747987.3740	1442616.4873	7775940	60
==================================================================================================================================================================
POPULARITY QUERY
==================================================================================================================================================================
SELECT
	AVG(popularity.popularity) AS meanPop,
	STD(popularity.popularity) AS stdPop,
	MAX(popularity.popularity) AS maxPop,
	MIN(popularity.popularity) AS minPop
FROM
    spl2.popularity;
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
80.7826	286.4692	18552	1
==================================================================================================================================================================
FINAL CONTROVERSY QUERY
==================================================================================================================================================================
SELECT
	inraw.bibNumber,
	AVG(popularity.popularity) / 18552 + (STD(UNIX_TIMESTAMP(inraw.cin) - UNIX_TIMESTAMP(inraw.cout))) /7775136  AS controversy,
	inraw.itemtype,
	inraw.title,
	inraw.deweyClass,
	inraw.subj
FROM
    (SELECT * FROM spl2.inraw WHERE deweyClass >= 210 AND deweyClass < 220) AS inraw, spl2.popularity
WHERE
	( UNIX_TIMESTAMP(inraw.cin) - UNIX_TIMESTAMP(inraw.cout) ) > 0
AND
	( UNIX_TIMESTAMP(inraw.cin) - UNIX_TIMESTAMP(inraw.cout) ) < 7776000
AND
	inraw.bibNumber = popularity.bib
GROUP BY bibNumber
ORDER BY controversy;
==================================================================================================================================================================