Practice Character, Date & Numeric Functions (Banking & FinTech)

๐Ÿ“– 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:

  1. Show first name in INITCAP
  2. Find length of email IDs
  3. Replace fintrust.com with bank.com
  4. 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

  1. Find customers created in last 6 months
  2. Show last day of account opening month
  3. 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

  1. Show CEIL & FLOOR of transaction amounts
  2. Calculate monthly interest from yearly rate
  3. 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.

Scroll to Top