Sql (1 Viewer)

SantoR

Registered User.
Local time
Today, 13:49
Joined
Apr 20, 2015
Messages
38
i have a table where i am maintaining the status of the record as completed or not using Yes/No.
now to generate the report i need to show (#record completed)/(#record), and there are some where clause also.

can i write like

SELECT [(Count(tbl_status = -1)/Count(tbl_status))*100] AS [Rate]" from tbl where.... group by....
 

marlan

Registered User.
Local time
Today, 11:19
Joined
Jan 19, 2010
Messages
409
SELECT [(Count(tbl_status = -1)/Count(tbl_status))*100] AS [Rate]" from tbl where.... group by....

(tbl_status = -1) is an expression, the query would count these expessions, 1 per record...

try this:
SELECT [(SUM(iif(tbl_status = -1,1,0))/Count(tbl_status))*100] AS [Rate]" from tbl

ATB!
 

SantoR

Registered User.
Local time
Today, 13:49
Joined
Apr 20, 2015
Messages
38
thanks ...it's a great trick..
 

Users who are viewing this thread

Top Bottom