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
 General SQL Server Forums
 New to SQL Server Programming
 count field is null

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2015-01-22 : 23:52:44
I have a table with 4 column in below

Total amount = 1000
salemancode1 = space
salemancode2 = Staff-99
salemancode3 = space
salemancode4 = staff-88

how I can write a one query statement to do this, we expect to count how many salemancode is not space and count the number of salesman to
over the total amount.

total amount / (no_of_saleman) as commission
the result is 1000/ 2 the commission is $500.

viggneshwar
Yak Posting Veteran

86 Posts

Posted - 2015-01-23 : 04:48:06
select count(case when salesmancode = '' then null else salesmancode end)
from tablename

Regards
Viggneshwar A
Go to Top of Page
   

- Advertisement -