How to get the size of selected rows in bytes using a single SQL query?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 12:13 AM
Hi all,
I have a table named employee in Databricks. I ran the following query to filter out rows where the salary is greater than 25000.
This query returns 10 rows. I want to find the size of these 10 rows in bytes, and I would like to calculate or retrieve this size only within the same query. How can I achieve this?
Any help would be appreciated!
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 12:42 PM
Hi @Akshay_Petkar,
You can try with this query:
SELECT SUM(LENGTH(CAST(employee.* AS STRING))) AS total_size_in_bytes
FROM employee
WHERE salary > 25000;

