|  | Posted by SQL Menace on 10/13/06 16:30 
Integer math
 here are 3 ways pick your poison
 
 select 3/4,
 (3*1.0)/4,
 3.0/4,
 convert(decimal(12,3),3)/4
 
 Denis the SQL Menace
 http://sqlservercode.blogspot.com/
 
 
 sqlservernew...@yahoo.com wrote:
 > Hello,
 >
 > I'm trying to something that just works in Oracle, but does not in Sql
 > Server.
 >
 > How can I get the percentage of two counts to be returned on each row
 > of the query?
 >
 > select count(sid),   /* all not the not null */
 > 	count(*),
 > (count(sid) /	count(*)  ) as percent_not_null,
 > 4  as four,
 > (3/4) as three_over_four
 > from dbo.sysusers
 >
 >
 > 70	82	0	4	0
 >
 >
 > Incredibly, it changes even 3/4 into a zero!
 >
 > For efficiency, I want the percentage returned in the query.
 > And to not use variables and coding.  Efficiency,
 > both of the server, and of my time.
 >
 >
 > Note:  I am using dbo.sysusers as an EXAMPLE only.  My real
 > query will be on user defined application tables.
 >
 >
 > What is the solution please?
  Navigation: [Reply to this message] |