Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003

    Unhappy Unanswered: query round off to real values returned ever.

    The query below gets percentage of coils for a location by anneal cycle. It does this correctly (ie, if you change count(*)/ to count(*), ... show both columns, the numbers its pulling are correct), but in its current state (trying to divide count by total), it always returns a zero (no decimal values).

    If I change that section to : (count(*)*100/*100)/100, I get integer percentages: no decimals (this is a problem because some records round off to zero). I'm pretty sure this is the entire problem (why I'm getting zeros as written below), but I don't have a clue how to fix it. Is this some kind of server setting that allows the query to only return decimal values or something?

    select a.department, a.cycle, count(*)/ percentage
    from inventory a join (select department, count(*) total from inventory
    		   where location not like 'bas%' and archived = 0 and quality_code = 'p'
    		   group by department) b on a.department = b.department
    where a.archived = 0 and a.quality_code = 'p' and location not like 'bas%'
    group by a.department, a.cycle,
    order by a.department, a.cycle

  2. #2
    Join Date
    Jan 2004
    (total*1.00) or convert(.....

  3. #3
    Join Date
    Dec 2003
    oh, yeah. thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts