I am using this code to get how many books that were loaned out by format. How do I get the sum of the Item_Count column? I see many examples using the SUM query but none that included pulling other data in . Can you help me please?
SELECT A.Category, COUNT(*) AS ITEM_COUNT FROM LOAN B JOIN LIBRARY A ON B.ITEM_IDNO = A.IDNO WHERE B.LOANDATE < CURRENT_DATE AND B.LOANDATE >= CURRENT_DATE-30 GROUP BY Category;
SELECT A.CATEGORY, COUNT(*) AS ITEM_COUNT FROM LOAN B JOIN LIBRARY A ON B.ITEM_IDNO=A.IDNO WHERE B.LOANDATE < CURRENT_DATE AND B.LOANDATE>=CURRENT_DATE-30 GROUP BY CATEGORY UNION ALL SELECT 'SUM' ITEM_IDNO, COUNT(*) FROM LOAN WHERE LOANDATE < CURRENT_DATE AND LOANDATE>=CURRENT_DATE-30;
Tables and fields used in the query:
A - Libary Items table (LIBRARY)
B - Loans table (LOAN)
Handy Library Manager
Copyright © 2022 · All Rights Reserved · PrimaSoft PC