#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
SQL for Testers

Single Row Function / Multiple Row Function

Single Row Functions

Operate on one row at a time and return one result per row, regardless of how many rows the query processes — for example, UPPER(name) or ROUND(salary, 2).

Multiple Row (Aggregate) Functions

Operate across a group of rows and return a single summarized result — for example, COUNT(*), SUM(salary), AVG(salary), MAX(salary), and MIN(salary).

Using GROUP BY

Aggregate functions are often combined with GROUP BY to summarize data per category, e.g. SELECT department, COUNT(*) FROM employees GROUP BY department;

Why the Distinction Matters for Testing

Knowing which type of function to use lets testers quickly verify things like total record counts, sums, or per-row transformations when validating data against expected results.

Categories of Single Row Functions

Single row functions are grouped by the kind of data they work on. Names differ slightly between databases, so the examples below note common variants.

CategoryExamplesTypical use in testing
CharacterUPPER, LOWER, TRIM, SUBSTR/SUBSTRING, LENGTH/LENCheck that names are stored without extra spaces
NumberROUND, TRUNC, MOD, ABSVerify rounding of prices and taxes
DateSYSDATE, CURRENT_DATE, DATEDIFF, ADD_MONTHSConfirm expiry dates and ages
ConversionCAST, TO_CHAR, TO_DATE, CONVERTCompare values stored as text with real numbers
General / null handlingCOALESCE, NVL, IFNULL, CASEReplace missing values before comparison

Validation Queries a Tester Actually Writes

Here are a few realistic checks on an employees table after a data migration. Each one targets a specific kind of defect.

-- Names saved with leading or trailing spaces (single row function)
SELECT id, name
FROM employees
WHERE name <> TRIM(name);

-- Emails not stored in lower case
SELECT id, email
FROM employees
WHERE email <> LOWER(email);

-- Row count and salary total must match the source system
SELECT COUNT(*) AS total_rows, SUM(salary) AS total_salary
FROM employees;

-- Departments with more than 50 people (aggregate + HAVING)
SELECT department, COUNT(*) AS headcount
FROM employees
GROUP BY department
HAVING COUNT(*) > 50;

-- Duplicate employee codes
SELECT emp_code, COUNT(*) AS copies
FROM employees
GROUP BY emp_code
HAVING COUNT(*) > 1;

The first two queries run a function on every row and compare it with the stored value. The last three collapse many rows into one result per group, which is ideal for reconciling totals between systems.

WHERE vs HAVING and How NULLs Behave

WHERE filters individual rows before grouping, so it can use single row functions but not aggregates. HAVING filters groups after aggregation, so it is where conditions like COUNT(*) > 1 belong. Writing WHERE COUNT(*) > 1 produces an error.

Aggregate functions skip NULL values, with one exception: COUNT(*) counts every row. This difference matters when you test:

  • COUNT(*) counts all rows; COUNT(bonus) counts only rows where bonus is not NULL.
  • AVG(bonus) divides by the non-null count, so it may be higher than you expect. Use AVG(COALESCE(bonus, 0)) if missing bonuses should count as zero.
  • SUM of a column that is entirely NULL returns NULL, not zero.

Mistakes and a Tester's Checklist

  • Mixing grouped and ungrouped columns. Every selected column that is not aggregated must appear in GROUP BY.
  • Forgetting that functions differ by database. NVL is Oracle, IFNULL is MySQL, ISNULL is SQL Server; COALESCE works almost everywhere.
  • Wrapping indexed columns in functions on large tables. It can force a full scan and slow your validation query.
  • Comparing totals without matching filters. Source and target counts must use the same date range and status rules.

When validating data, check row counts, key totals, duplicates, nulls in mandatory columns and formatting of text fields. Those five checks catch most migration defects.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course