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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Nested SELECT

Author  Topic 

mmalaka
Starting Member

33 Posts

Posted - 2011-09-16 : 06:49:05
Experts,

I am trying to do the following:

Select Table1.Field1, Expr From Table1, Table2

Expr is the Count of records in Table2 where a Field is equal the value of Table1.Field1. I think it is a Nested Select and the internal select depend on the value of the external select.

Any advice Please
Thanks


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-16 : 07:34:13
Please show us sample data to make your problem clear.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lewie
Starting Member

42 Posts

Posted - 2011-09-16 : 08:24:09
select Table1.Field1,(select COUNT(*) from Table2 where Table2.Field1 = Table1.Field1) from Table1
Go to Top of Page
   

- Advertisement -