SELECT
    printf(
        '%02d:%02d:%02d',
        AVG((substr(tempo_faturamento,1,2) * 3600) +
            (substr(tempo_faturamento,4,2) * 60) +
            (substr(tempo_faturamento,7,2))) / 3600,
        (AVG((substr(tempo_faturamento,1,2) * 3600) +
             (substr(tempo_faturamento,4,2) * 60) +
             (substr(tempo_faturamento,7,2))) % 3600) / 60,
        AVG((substr(tempo_faturamento,1,2) * 3600) +
            (substr(tempo_faturamento,4,2) * 60) +
            (substr(tempo_faturamento,7,2))) % 60
    ) AS tempo_medio
FROM faturamento;

SELECT 
    transportadora,
    COUNT(*) AS total_tickets
FROM faturamento
GROUP BY transportadora
ORDER BY total_tickets DESC;

SELECT
    printf(
        '%02d:%02d:%02d',
        AVG((substr(tempo_no_patio,1,2) * 3600) +
            (substr(tempo_no_patio,4,2) * 60) +
            (substr(tempo_no_patio,7,2))) / 3600,
        (AVG((substr(tempo_no_patio,1,2) * 3600) +
             (substr(tempo_no_patio,4,2) * 60) +
             (substr(tempo_no_patio,7,2))) % 3600) / 60,
        AVG((substr(tempo_no_patio,1,2) * 3600) +
            (substr(tempo_no_patio,4,2) * 60) +
            (substr(tempo_no_patio,7,2))) % 60
    ) AS tempo_medio
FROM pesagem;

SELECT 
    produto,
    SUM(peso) AS total_peso
FROM faturamento
GROUP BY produto
ORDER BY total_peso DESC;

SELECT
    colaborador,
    printf('%02d:%02d',
        CAST(((julianday(saida) - julianday(entrada)) * 24) AS INTEGER),
        CAST((((julianday(saida) - julianday(entrada)) * 24 * 60) 
               % 60) AS INTEGER)
    ) AS horas_formatadas
FROM biometria;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: