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
 How do I get 2% of a count in this SQL?

Author  Topic 

Maverick_
Posting Yak Master

107 Posts

Posted - 2012-06-22 : 06:58:49
Hi all,

I have this sub-select query which aims to count all the "features" in a database of a certain type.

What I want to do in this SQL is make it just the 2% of the total count (whatever that is as the number changes when new records are added).

(SELECT count(*)
FROM
feat_attrib_type,
feature
WHERE
feature.site_code = feat_attrib_type.site_code AND
feature.plot_number = feat_attrib_type.plot_number AND
feature.feature_deadflag <> 'Y' AND
feat_attrib_type.attrib_type_code = 'GC' AND
feat_attrib_type.attrib_value_code = '1') as Count



Any ideas how I can calculate the 2% of this count and show it in the results?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-06-22 : 07:06:02
/100*2 as Count


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-06-22 : 07:07:55
Multiply the COUNT(*) by 0.02. Or is there more to what you are asking?
SELECT count(*) * 0.02 
FROM
feat_attrib_type,
feature
WHERE
....
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-06-22 : 07:21:43


But mine has only one arithmetic operation, so that should count for something!!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-06-22 : 07:26:44
quote:
Originally posted by sunitabeck



But mine has only one arithmetic operation, so that should count for something!!





No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -