A suspicious transaction doesn't necessarily mean someone has committed fraud. This is something that becomes increasingly clear when you start working with banking data.

Imagine a customer making several high-value transactions within an hour. It could be someone shopping for a wedding, a business owner paying suppliers, or someone using a compromised account.

The data might look similar in all three cases.

That's what makes fraud analytics interesting. Finding unusual activity is relatively straightforward. Understanding what that activity actually means is the difficult part.

While there is a lot of discussion around AI and machine learning in fraud detection, SQL remains an incredibly useful tool for investigating suspicious behaviour.

Here are five examples worth exploring if you're interested in banking, data analytics or financial crime investigation.

The examples use fictional banking data and PostgreSQL syntax.

1. When transaction frequency suddenly increases

Banks process millions of transactions, and customers have different spending habits. Rather than looking at transaction amounts alone, analysts can also examine how frequently transactions occur.

A simple exploratory query might look like this:

SELECT customer_id, COUNT(*) AS transaction_count, SUM(amount) AS total_amount FROM transactions WHERE transaction_time >= CURRENT_TIMESTAMP - INTERVAL '1 hour' GROUP BY customer_id ORDER BY transaction_count DESC; 

The interesting part is what happens after running the query.

A customer appearing at the top of the results isn't necessarily suspicious. Someone who regularly makes business payments may have a perfectly reasonable explanation for their activity.

Comparing recent activity with historical behaviour gives the analyst more context than transaction frequency alone.

2. Finding duplicate transactions

Duplicate transactions are something analysts frequently encounter while working with financial data.

Sometimes they're caused by processing errors. In other cases, they may be associated with suspicious activity or problems in the payment system.

SELECT customer_id, merchant_id, amount, transaction_time, COUNT(*) AS occurrence_count FROM transactions GROUP BY customer_id, merchant_id, amount, transaction_time HAVING COUNT(*) > 1; 

This identifies records sharing the same customer, merchant, amount and timestamp.

One thing to be careful about here is data quality. If an upstream process has loaded the same records twice, the query could produce misleading results.

Before investigating a customer, it makes sense to investigate the data itself.

Not every problem appearing on a fraud dashboard is actually a fraud problem.

3. Understanding changes in customer spending

Suppose a customer generally makes small purchases, but their recent spending looks considerably different.

Instead of applying the same assumptions to every customer, we can calculate an individual historical spending baseline.

SELECT customer_id, AVG(amount) AS average_amount, MIN(amount) AS minimum_amount, MAX(amount) AS maximum_amount, COUNT(*) AS transaction_count FROM transactions WHERE transaction_time >= CURRENT_TIMESTAMP - INTERVAL '90 days' AND transaction_time < CURRENT_TIMESTAMP - INTERVAL '1 day' GROUP BY customer_id; 

This gives us a basic picture of historical spending behaviour.

Of course, averages have limitations. A few exceptionally large transactions can distort the results. Customers with limited transaction history present another challenge.

Depending on the available data, median spending, transaction categories and longer-term behavioural patterns may provide a more useful comparison.

The SQL isn't particularly complicated. Deciding which comparison makes business sense requires more thought.

4. Looking beyond financial transactions

One of the more interesting aspects of banking fraud is that relevant information doesn't always originate from the transaction itself.

Customer service interactions, authentication events and account maintenance activities can provide additional context during an investigation.

For example, an analyst might want to understand the different account maintenance activities recorded across the customer population.

SELECT event_type, COUNT(*) AS total_events, COUNT(DISTINCT customer_id) AS customers FROM account_events GROUP BY event_type ORDER BY total_events DESC; 

This could include activities such as contact information updates, password changes or other account maintenance events.

These events are normal parts of banking operations. Their presence alone should never be treated as proof of fraud.

What matters is understanding the broader circumstances and evaluating the available evidence together.

This is also where fraud analytics starts moving closer to fraud investigation.

5. Checking whether your fraud data is reliable

This might not sound as exciting as building a machine learning model, but data quality deserves considerably more attention than it usually receives.

Imagine building a fraud dashboard where transaction IDs are duplicated or customer identifiers are missing.

Even a technically correct SQL query could produce an incorrect business conclusion.

Here's a basic validation query:

SELECT COUNT(*) AS total_records, COUNT(DISTINCT transaction_id) AS unique_transactions, SUM( CASE WHEN customer_id IS NULL THEN 1 ELSE 0 END ) AS missing_customer_ids, SUM( CASE WHEN amount IS NULL THEN 1 ELSE 0 END ) AS missing_amounts FROM transactions; 

I would encourage anyone learning fraud analytics to spend some time understanding data validation, reconciliation and completeness checks.

These skills are just as valuable as knowing window functions, joins or advanced SQL techniques.

A beautiful dashboard built on unreliable data isn't particularly useful.

Where fraud examination fits into all of this

SQL can help answer questions about what happened, how frequently something occurred and whether certain patterns exist.

It cannot independently determine whether someone intended to commit fraud.

That requires an understanding of evidence, internal controls, investigative procedures and the circumstances surrounding an event.

This is one reason why the Certified Fraud Examiner (CFE) credential is relevant to professionals working in fraud analytics, banking, risk management and financial crime.

The technical side helps you find unusual patterns. Fraud examination helps you understand how to evaluate them.

For anyone interested in developing that knowledge alongside their technical skills, FinCertPrep is an independent CFE preparation and fraud education platform.

Official certification requirements and examination information are available directly from the Association of Certified Fraud Examiners.

Something worth thinking about

If your SQL query identifies 500 suspicious transactions, but only five eventually turn out to be confirmed fraud, was your analysis successful?

There isn't a universal answer.

You would need to understand the financial losses prevented, the investigation workload, the impact on genuine customers and the purpose of the original detection rule.

These are the kinds of questions that make fraud analytics more than just a technical discipline.

Learning SQL is a great starting point. Learning how to ask the right business questions is what makes the technical knowledge valuable.

I'd be interested to hear how others working in banking, financial crime or data analytics approach this problem. Do you prefer starting with SQL-based analysis or moving directly towards statistical and machine learning models?

Disclosure: This article introduces FinCertPrep, an independent educational platform that is not affiliated with the ACFE.