RE: Query Help

RE: Query Help

 

  

I think if you just specify count(*) in the select list, then group by all
the other fields it should work. Question is, does it? Note, the group by
might omit some columns or have to many in my example below


SELECT
A.COM_NAME,B.ContractName,B.ContractCode,B.EXT_Employees,B.K_EMPLOYEES,B.F_E
MPLOYEES,B.T_EMPLOYEES,
cast((cast(b.K_Employees as float) / cast((F_Employees+K_EMPLOYEES)
as float))*100 as char)+'%'
as "Employees Percentage", count(*) kount
FROM K_COMPANIES A
INNER JOIN Contracts B ON A.K_ID=B.K_ID
Group by
A.COM_NAME,B.ContractName,B.ContractCode,B.EXT_Employees,B.K_EMPLOYEES,
B.F_EMPLOYEES,B.T_EMPLOYEES, b.K_Employees, F_Employees, K_EMPLOYEES

-----Original Message-----
From: YIF [mailto:mssqldba-ezmlmshield-x28541054.[Email address protected]
Sent: Tuesday, February 28, 2006 12:44 PM
To: LazyDBA Discussion
Subject: Query Help



Dear All
can i use the count function in this query

SELECT
A.COM_NAME,B.ContractName,B.ContractCode,B.EXT_Employees,B.K_EMPLOYEES,B.F_E
MPLOYEES,B.T_EMPLOYEES,
cast((cast(b.K_Employees as float) / cast((F_Employees+K_EMPLOYEES)
as float))*100 as char)+'%'
as "Employees Percentage"
FROM K_COMPANIES A
INNER JOIN Contracts B ON A.K_ID=B.K_ID

i need to count the number of Percentage, but i'm having problem using it
with thethe case function
For example i need to count
cast((cast(b.K_Employees as float) / cast((F_Employees+K_EMPLOYEES)
as float))*100 as char)+'%'
as "Employees Percentage"

Kind Regards





---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Website : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html



MS Sql Server LazyDBA home page