Name | CountWin | CountFail | Failure% |
---------------------------------
TypeA | 100 | 50 | 50 |
TypeB | 100 | 5 | 5 |
TypeC | 100 | 100 | 100 |
TypeD | 100 | 0 | 0 |
I am trying to create the above table with sql. The results are not what I expect though. The results are below
Name | CountWin | CountFail | Failure% |
---------------------------------
TypeA | 100 | 50 | 0 |
TypeB | 100 | 5 | 0 |
TypeC | 100 | 100 | 0 |
TypeD | 100 | 0 | 0 |
The sql code:
INSERT INTO #my_temp_table
select type, date, CountWin, CountFail from myTable
select type, SUM(CountWin) as CountWin, SUM(CountFail) as CountFail, (((SUM(CountFail) / SUM(CountWin)) * 100) as Failure%
FROM #my_temp_table
WHERE date > DATEADD(day, -7, getdate())
GROUP BY type, date
Just wondering why my (((SUM(CountFail) / SUM(CountWin)) * 100 is not returning proper values