|
Posted by Erland Sommarskog on 04/10/06 13:28
Igor (jerosimic@gmail.com) writes:
> I wrote it like this:
> SELECT projects.project_id, projects.project_title,
> projects.project_description, (SELECT count(*) FROM users WHERE
> projects.project_id=users.project_id) AS number_od_users
> FROM projects;
This is most likely slower than the version I suggested. Sub-selects in the
SELECT list often gives poor performance.
> what does "coalesce" do?
coalesce takes list of values, and returns the first non-NULL value in the
list, or NULL if all values are NULL.
coalesce() is described in Books Online, if you want to read more.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|