Ask SQLTeam Question
Posted - 06/16/2006 : 08:45:31
| Sue writes "Hello, I have this Access SQL query and I would like to convert it to SQL Server query:
SELECT dbo_state_lang_cds.slc_desc, Count(dbo_FRWCServices.Service2) AS CountOfService2, Count(dbo_FRWCServices.ClientID) AS CountOfClientID
FROM (dbo_FRWCClientInfo INNER JOIN dbo_FRWCServices ON dbo_FRWCClientInfo.ClientID = dbo_FRWCServices.ClientID) INNER JOIN dbo_state_lang_cds ON dbo_FRWCClientInfo.Lang = dbo_state_lang_cds.slc_code
GROUP BY dbo_state_lang_cds.slc_desc, dbo_FRWCClientInfo.Lang
ORDER BY dbo_FRWCClientInfo.Lang;
This is the SQL query that I'm trying to update:
select s.lang, l.slc_desc, count(*) as 'SvcCount', count(distinct clientid) as 'clientCount',
cast(count(*)as float) / cast (count(distinct clientid) as float) as 'Avg # of Services Per client'
from frwcservices s
inner join FRWCServices ON FRWCClientInfo.ClientID = FRWCServices.ClientID
left join sms.dbo.state_lang_cds l on s.lang = l.slc_code
group by s.lang, l.slc_desc
What I am trying to do is in the SQL query, bring in the ClientID field from the FRWCClientInfo.
There are two language fields (one in the FRWCServices table and one in the FRWCClientInfo table) and I want to know the average services, etc, but instead of the FRWCServices table, I now want to add a join to the FRWCClient info table.