๐ Introduction
In Banking and FinTech applications, Oracle SQL functions are used daily for:
- Customer data standardization
- Interest & EMI calculation
- Transaction analysis
- Inactive account detection
- Compliance and reporting
This blog provides a complete hands-on business case study to practice Oracle SQL Character, Date, and Numeric functions, exactly how they are used in real banking databases.
This guide is ideal for:
- Freshers (0โ2 years)
- Experienced professionals (3โ8 years)
- Oracle interview preparation
- Real project practice
๐๏ธ Business Scenario โ FinTrust Digital Bank
FinTrust Bank is a digital bank offering:
- Savings & Current accounts
- Digital transactions
- Loan products
As a SQL Developer / Data Analyst, your responsibility is to write SQL queries using built-in Oracle functions to generate reports and insights.
๐๏ธ Database Schema
1๏ธโฃ CUSTOMER_MASTER Table
๐ Purpose
Stores customer demographic and KYC information.
CREATE TABLE customer_master (
customer_id NUMBER PRIMARY KEY,
first_name VARCHAR2(50) NOT NULL,
last_name VARCHAR2(50),
email_id VARCHAR2(100) UNIQUE,
mobile_number VARCHAR2(15),
date_of_birth DATE NOT NULL,
gender CHAR(1) CHECK (gender IN ('M','F')),
created_date DATE DEFAULT SYSDATE
);
๐น Sample Data
INSERT INTO customer_master VALUES
(101, 'Rahul', 'Sharma', 'rahul.sharma@fintrust.com', '98xxxxxxxx', DATE '1990-05-15', 'M', SYSDATE-500);
INSERT INTO customer_master VALUES
(102, 'Anita', 'Verma', 'anita.verma@fintrust.com', '98xxxxxxxx', DATE '1985-12-10', 'F', SYSDATE-800);
INSERT INTO customer_master VALUES
(103, 'Vijay', NULL, 'vijay@fintrust.com', '98xxxxxxxx', DATE '2000-01-25', 'M', SYSDATE-200);
2๏ธโฃ ACCOUNT_MASTER Table
CREATE TABLE account_master (
account_id NUMBER PRIMARY KEY,
customer_id NUMBER REFERENCES customer_master(customer_id),
account_number VARCHAR2(20) UNIQUE NOT NULL,
account_type VARCHAR2(20) CHECK (account_type IN ('SAVINGS','CURRENT','LOAN')),
balance NUMBER(15,2),
open_date DATE,
status VARCHAR2(10)
);
๐น Sample Data
INSERT INTO account_master VALUES
(201, 101, 'FTSAV1001', 'SAVINGS', 125000.75, SYSDATE-400, 'ACTIVE');
INSERT INTO account_master VALUES
(202, 102, 'FTCUR2001', 'CURRENT', 850000.00, SYSDATE-1000, 'ACTIVE');
INSERT INTO account_master VALUES
(203, 103, 'FTSAV1002', 'SAVINGS', 4500.25, SYSDATE-50, 'INACTIVE');
3๏ธโฃ TRANSACTION_DETAILS Table
CREATE TABLE transaction_details (
txn_id NUMBER PRIMARY KEY,
account_id NUMBER REFERENCES account_master(account_id),
txn_date DATE,
txn_type VARCHAR2(10) CHECK (txn_type IN ('CREDIT','DEBIT')),
amount NUMBER(12,2),
remarks VARCHAR2(100)
);
๐น Sample Data
INSERT INTO transaction_details VALUES
(301, 201, SYSDATE-10, 'CREDIT', 50000, 'Salary Credit');
INSERT INTO transaction_details VALUES
(302, 201, SYSDATE-5, 'DEBIT', 1200.50, 'ATM Withdrawal');
INSERT INTO transaction_details VALUES
(303, 203, SYSDATE-2, 'DEBIT', 500, 'UPI Payment');
๐งช Hands-On Lab โ Oracle SQL Functions
๐ค LAB 1: Character / String Functions
๐งโ๐ผ Task 1: Display Full Customer Name in Uppercase
SELECT customer_id,
UPPER(first_name || ' ' || NVL(last_name,''))
FROM customer_master;
๐ง Task 2: Mask Customer Email ID
SELECT email_id,
SUBSTR(email_id,1,3) || '*****' ||
SUBSTR(email_id, INSTR(email_id,'@'))
FROM customer_master;
๐ฑ Task 3: Format Mobile Numbers to 12 Digits
SELECT LPAD(mobile_number, 12, '0')
FROM customer_master;
๐งช Exercise โ Character Functions
Try writing SQL queries to:
- Show first name in INITCAP
- Find length of email IDs
- Replace
fintrust.comwithbank.com - Display customers whose last name is NULL
๐ LAB 2: Date Functions
๐ Task 4: Calculate Customer Age
SELECT customer_id,
FLOOR(MONTHS_BETWEEN(SYSDATE, date_of_birth)/12) AS age
FROM customer_master;
๐ Task 5: Find Accounts Older Than 1 Year
SELECT account_number
FROM account_master
WHERE open_date < ADD_MONTHS(SYSDATE, -12);
๐ Task 6: Current Month Transactions
SELECT *
FROM transaction_details
WHERE TRUNC(txn_date,'MM') = TRUNC(SYSDATE,'MM');
๐งช Exercise โ Date Functions
- Find customers created in last 6 months
- Show last day of account opening month
- Display day name of each transaction
๐ข LAB 3: Numeric Functions
๐ฐ Task 7: Calculate Yearly Interest (4%)
SELECT account_number,
ROUND(balance * 0.04, 2) AS yearly_interest
FROM account_master
WHERE account_type = 'SAVINGS';
๐งฎ Task 8: EMI Approximation
SELECT account_number,
ROUND((balance * 0.01 * POWER(1.01,12)) /
(POWER(1.01,12)-1),2) AS EMI
FROM account_master;
๐ Task 9: Absolute Transaction Amount
SELECT txn_id, ABS(amount)
FROM transaction_details;
๐งช Exercise โ Numeric Functions
- Show CEIL & FLOOR of transaction amounts
- Calculate monthly interest from yearly rate
- Find MOD of transaction amount with 100
๐ง Advanced Real-World Banking Exercises
๐จ Exercise 1: Identify Inactive Accounts (No Txn in 90 Days)
SELECT a.account_number
FROM account_master a
WHERE NOT EXISTS (
SELECT 1
FROM transaction_details t
WHERE t.account_id = a.account_id
AND t.txn_date > SYSDATE - 90
);
๐ Exercise 2: Low Balance Alert (< โน5000)
SELECT account_number, balance
FROM account_master
WHERE balance < 5000;
๐งพ Exercise 3: Monthly Statement Report
- Customer Name
- Account Number
- Month
- Total Credit
- Total Debit
(Hint: Use TRUNC, SUM, GROUP BY)
โ Interview-Important Functions Covered
๐ค Character Functions
UPPER, LOWER, INITCAP, SUBSTR, INSTR, LENGTH, LPAD, NVL, REPLACE, TRIM
๐ Date Functions
SYSDATE, ADD_MONTHS, MONTHS_BETWEEN, TRUNC, LAST_DAY, NEXT_DAY
๐ข Numeric Functions
ROUND, CEIL, FLOOR, ABS, POWER, MOD
๐ Disclaimer
This content is created for educational and interview preparation purposes only. Database structures and data are simplified and do not represent any real banking system.
