0
我想在spiceworks中創建一個需要上個月數據的報告。我在這裏看到了這個鏈接:Query last day, last week, last month SQLite但是這個月的例子只返回當前月份。我需要上個月。該報告將在每個月的第一天,在這裏跑出就是我迄今:SQLite上個月
SELECT a.id as "Ticket #", c.first_name||' '|| c.last_name as "Created By", a.c_location as "Location",
a.c_hud as "HUD", a.closed_at as "Closed", a.c_urgency as "Urgency", a.category as "Category",
a.summary as "Summary", SUM(b.time_spent)/3600.0 as "Time Spent (Hrs)",
d.price*d.quantity as "Purchases"
FROM tickets a
LEFT OUTER JOIN ticket_work b ON a.id = b.ticket_id
LEFT OUTER JOIN purchase_list_items d on a.id = d.ticket_id
JOIN users c ON a.created_by = c.id
WHERE closed_at BETWEEN datetime('now', 'start of month') AND datetime('now','localtime')
GROUP BY a.id
ORDER BY c_location;
一旦我把它拉正確的數據集,我必須將總b.time_spent領域這是整數轉換鍵入,轉換爲小時格式。因此,如果花費的時間爲33600,那麼我需要將輸出轉換爲9.33,否則就是當前輸出的9。它目前只給我任何幫助將不勝感激。
sql語句包括CLs建議修復小數點問題 – Azulitabijou