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.
| Author |
Topic |
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2008-04-02 : 10:27:03
|
| Morning/Afternoon,Hope you can help me, I have tried serval ways to do this. What i have is a User table which links to a search table and downlaods table, both the latter tables can be joined to the user table by the userid. What I am trying to do is get the user table join to the user and download table and get a count() value from them. SELECT [dbo].[UserTable].[lCompanyId], [dbo].[UserTable].[sUserName], COUNT(ldocumentId), COUNT(Search.[lSearchID])FROM [dbo].[UserTable] left JOIN [dbo].Download ON [dbo].[UserTable].[lUserId] = [dbo].Download.[lUserId] JOIN dbo.Search ON [dbo].[Search].[lUserID] = [dbo].[UserTable].[lUserId]WHERE [UserTable].luserid = 45307GROUP BY [dbo].[UserTable].[lCompanyId], [dbo].[UserTable].[sUserName] |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-04-02 : 10:30:40
|
| count(distinct ...) instead?Em |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-02 : 12:42:04
|
| Please specify what problem you're facing with above query & complement it with some sample data & o/p |
 |
|
|
|
|
|