Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Returning no record instead of null

Author  Topic 

sqlbug
Posting Yak Master

201 Posts

Posted - 2009-04-22 : 18:15:43
I was wondering if there is a way to return no record from a query thats returning NULL now when there are no matching records. Here's this one:
SELECT AVG(DATA_VALUE) FROM...
WHERE...

Thanks.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-04-22 : 19:14:26
[code]if not exists(SELECT AVG(DATA_VALUE) FROM...WHERE...)
select null

SELECT AVG(DATA_VALUE) FROM...WHERE...[/code]
Go to Top of Page
   

- Advertisement -