I am executing a SQL query which scans couple of tables with million of rows.
What I was trying to implement was my select query should return result only if the result set contains only one row.
I knew these two approches to do it:
1) Use group by and then ‘having count( * )’
2) Use inner query which further uses ‘count( * ) over’
But both of these approches would hamper the performance.
I would like to know, if there is any other faster approach to do this. Let me know if you require more information.
Thanks.
like this for a pure SQL way.
of course, if your query has order by, it will have to scan the result set anyway (correct indexing + perhaps first rows hint will help if that is the case.)