34|SQL – Audit Attention

BYU Student Author: @DylanKing
Reviewers: @Christian, @Boston
Estimated Time to Solve: 15 Minutes

We provide the solution to this challenge using:

Need a program? Click here.

Overview
This challenge works in connection with Challenge 52|ALTERYX – Balance Sheet Boost. As a first-year associate who recently graduated from school, you have joined a small local accounting firm in the area. Your first assignment is to audit the Financial Statement Controls of a local chain of car repair shops. The senior member of the engagement team informed you that they had strengthened the controls around the income statement in the previous year. However, they remain concerned about some of the controls around certain balance sheet accounts that do not meet the firm’s standards.

You decide to use SQL to identify balance sheet accounts that require the most attention during the audit. After meeting with others on the engagement team, you determine that accounts that have 1,000 transactions or more during the month and have an ending debit or credit balance of 50,000 or more will require the most attention. You notify the other members of the audit engagement that you will find which accounts meet these criteria.

Instructions

  1. First, import all the sheets of data into access or whichever program you choose to practice SQL.
  2. Second, verify that the relationships between the various excel sheets are correct. If there aren’t any relationships identified, create the relationships yourself.
  3. Third, write the SQL code to identify which accounts meet the aforementioned criteria. Remember, accounts must have 1,000 transactions or more and have an ending debit or credit balance of 50,000 or more. Sort by the number of transactions in descending order and be sure to sort out the data that has a null account number. After running your SQL code, the table you return should have the following columns: Acct, GLAcctDesc, EndingDebitBalances, NumOfTransactions.

Data Files

Suggestions and Hints
  1. When creating the relationships between the various tables, be sure to connect them on the account number
  2. When trying to find the accounts that follow the criteria of having an ending debit or credit balance of $50,000 or more, remember that we are given the ending debit balance. I wrote an absolute value in my code to find the accounts with an ending credit balance of $50,000 or more because they will be written as negative numbers in our data.

Solution

Thank you Dylan for the SQL practice! It was a great, short, and sweet practice!

6 Likes

This was a good quick SQL review! Here’s the solution I came up with:
SELECT e.Acct, e.GLAcctDesc, e.EndingDebitBalances, Count(g.ID) AS NumTrans
FROM EndingBalances AS e LEFT JOIN GeneralJournal AS g ON e.Acct = g.Acct
WHERE (((Abs([e].[EndingDebitBalances]))>=50000) AND ((e.Acct) Is Not Null))
GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances
HAVING (((Count(g.ID))>=1000));

8 Likes

select e.Acct,
e.GLAcctDesc,
e.EndingDebitBalances,
count(g.ID) as NumOfTransactions
from EndingBalances e
left join GeneralJournal g on g.Acct = e.Acct
where ABS(EndingBalances.EndingDebitBalances) >= 50000
group by g.Acct
having NumOfTransactions >= 1000
order by NumOfTransactions desc;

4 Likes

Thanks for the challenge and SQL refresher! Here is the Solution that I came up with for this challenge:

a. SELECT e.Acct, e.GLAcctDesc, e.EndingDebitBalances, COUNT(g.ID) AS NumOfTransactions
FROM EndingBalances AS e INNER JOIN GeneralJournal AS g ON e.Acct = g.Acct
WHERE Abs(e.EndingDebitBalances)>=50000 AND e.Acct IS NOT NULL
GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances
HAVING COUNT(g.ID) >= 1000
ORDER BY COUNT(g.ID) DESC;

6 Likes

SELECT e.Acct, e.GLAcctDesc, Count(g.ID) AS NumTrans
FROM EndingBalances AS e LEFT JOIN GeneralJournal AS g ON e.Acct = g.Acct
WHERE Abs(e.EndingDebitBalances)>=50000
GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances

2 Likes

Thank you Dylan! This was a great refresher!

SELECT e.Acct, e.GLAcctDesc, e.EndingDebitBalances, Count(g.ID) AS NumOfTransactions
FROM EndingBalances AS e INNER JOIN GeneralJournal1 AS g ON e.Acct = g.Acct
WHERE (((e.EndingDebitBalances) Not Between -50000 And 50000))
GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances
HAVING (((Count(g.ID))>1000))
ORDER BY Count(g.ID) DESC;

I also tried an Alteryx Solution:

5 Likes

SELECT e.Acct, e.GLAcctDesc, Count(g.ID) AS NumTrans
FROM EndingBalances AS e LEFT JOIN GeneralJournal AS g ON e.Acct = g.Acct
WHERE Abs(e.EndingDebitBalances)>=50000
GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances

1 Like

Great SQL refresher! Here is my output solution!

3 Likes

This challenge was great. I learned how to use the SQL Server import & export wizard to import the excel file to my local sql server instance.

Here is my solution code:

SELECT
    eb.Acct
    , GLAcctDesc
    , EndingDebitBalances
    , a_count AS NumOfTransactions
FROM
    dbo.EndingBalances$ eb
    LEFT JOIN ( 
        SELECT Acct, COUNT(Acct) AS a_count 
        FROM GeneralJournal$ 
        GROUP BY Acct ) gj 
        ON eb.Acct = gj.Acct
WHERE 
    ABS(EndingDebitBalances) > 50000
    AND a_count > 1000
ORDER BY a_count DESC
2 Likes

This was a great refresher. Thanks!

2 Likes

Really enjoyed seeing an example that is relevant to reality!

SELECT e.Acct, e.GLAcctDesc, e.EndingDebitBalances, COUNT(g.ID) AS NumOfTransactions
FROM EndingBalances AS e LEFT JOIN GeneralJournal AS g ON e.Acct=g.Acct
WHERE e.Acct IS NOT NULL AND ABS(e.EndingDebitBalances)>=50000
GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances
HAVING COUNT(g.ID) >=1000
ORDER BY COUNT(g.ID) DESC;

3 Likes

Here is my solution!

SELECT e.Acct, e.GLAccDesc, e.EndingDebitBalances, COUNT (g.ID) AS NumberOfTransactions
FROM EndingBalances AS e LEFT JOIN GeneralJournal AS g ON e.Acct = g.Acct
WHERE Abs(e.EndingDebitBalances) >= 50000
GROUP BY g.Acct
HAVING NumberOfTransactions >= 1000
ORDER BY NumberOfTransactions DESC

Access was really picky so it took me longer than I’d like to admit. Great practice!

3 Likes

Here is my answer!

5 Likes

SELECT e Acct, e GLAcctDesc, e EndingDebitBalances, COUNT(g ID) AS NumOfTransactions FROM EndingBalances AS e LEFT JOIN Generallournal AS g ONe Acct=g Acct WHERE e AcctIS NOT NULL AND ABS(e EndingDebitBalances) > = 50000 GROUP BY e Acct, e GLAcctDese, e EndingDebitBalances HAVING COUNT(g.ID) » = 1000 ORDER BY COUNTIg.ID) DESC

Here is my solution. I won’t lie I couldn’t quite get the count to work on my own so I followed along after the first few lines. Great project though. Thanks for giving us a good starting challenge!

Here’s my answer! It was challenging enough to strengthen my skillset for sure

Needed the refresher! Thanks!! Here is my output solution.
Screenshot 2023-10-07 132006

1 Like

This challenge helped me better understand the importance of the absolute value function as an accountant when analyzing ending credit and debit balances.

Here is the query I generated for this challenge:

SELECT e.Acct, e.GLAcctDesc, e.EndingDebitBalances, COUNT(g.ID) AS NumOfTransactions

FROM EndingBalances AS e LEFT JOIN GeneralJournal AS g ON e.Acct = g.Acct

WHERE e.Acct IS NOT NULL AND ABS(e.EndingDebitBalances)>=50000

GROUP BY e.Acct, e.GLAcctDesc, e.EndingDebitBalances

HAVING COUNT(g.ID) >= 1000

ORDER BY COUNT(g.ID) DESC;

I found that the Machinery Inventory ending debit balance was the highest at 46,762,453.09.

This means that Machinery Inventory is an account that the audit engagement team should focus on. Great challenge!

2 Likes

image
Thanks for the helpful review of SQL! Definitely was able to re-learn some of the concepts and understand how to utilize them again.

This was my solution! This was an awesome exercise and helped me better understand Access and practice SQL.

SELECT g.Acct, e.GLAcctDesc, e.EndingDebitBalances, COUNT(g.ID) AS NumOfTransactions
FROM GeneralJournal1 as g RIGHT JOIN EndingBalances as e ON g.Acct=e.Acct
WHERE g.Acct IS NOT NULL AND ABS(e.EndingDebitBalances) >= 50000
GROUP BY g.Acct, e.GLAcctDesc, e.EndingDebitBalances
HAVING COUNT(g.ID) >=1000
ORDER BY COUNT(g.ID) DESC;