asp.net - SQL count all of the column that has a value greater than 10 and sum it up -


I want to count all the columns in my table, which has the value & gt; = 10. Here is my table:

Date ##### || Value1 || Value2 || Value 3

23/04/2014 || __ 1,2 || __ 12,3 || __10 ||

23/04/2014 || __ 11,2 || ____ 3 || __10,3 ||

24/04/2014 || __10 9 || ____ 3 || __ 1 ||

I want to display it:

Date ##### || Calculation ||

23/04/2014 || __ 4 ||

24/04/2014 || __ 1 ||

Let's say I have a lot of time, I want to display this only the last 3 rows.

This is my first code:

count (*)> = 10 group from tbount to date as tcount Select the count (*); Based on the solution from collapsar it has been changed:

  String = as the slow stromm = "select td, sum (t.valcount) cnt From (select [date] as d, case when t1.ManualAssists1 & Gt; = 10 THEN 1 ELSE 0 END + case when t1.ManualAssists2> = 10 THEN 1 ELSE 0 END + case when t1.ManualAssists3> = 10 THEN TD "by T / TT Group Group TBBooth T1 as 1 ELSE 0 END"   

This works , But I only want to display the last 3 lines based on the ASC order. How to do it anyway?

Thanks in advance ....

< Div class = "post-text" itemprop = "text">

Try

  select td, sum (t.valcount) from cnt (select [date] as d, case when t1.value1> = 10 THEN 1 ELSE 0 END + case when t1 value2> = 10 THEN 1 ELSE 0 END + case when t1.value3 & gt; = 10 THEN 1 ELSE 0 END as Table T / T by Group T) Group T;    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -