Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one,

I have a question : How can I take the range from 100 and above like from ** table?
For example, when I use the count(*) , it will take from 0 to ^^ , but my point is how to get it from 100 to ^^?

I think you get my point , any help will be useful

Best regards
ahmed
Posted
Updated 29-Nov-11 22:09pm
v2
Comments
Dalek Dave 30-Nov-11 4:09am    
Edited for Grammar and Syntax.

Try
SQL
SELECT COUNT(*) FROM myTable WHERE myValue > 99
 
Share this answer
 
Comments
Selva K 30-Nov-11 4:26am    
This work good
C#
select count(*) from (
 select ROW_NUMBER() over(order by pk)id,* from #leave
  ) a where id > 100


here

#leave    ---- Table Name
pk        ----- Primaary key of the table(you can use whatever you want)
in where condition you can put you condition.
if you want start count from 100 to 199 jut put the condition
like

where id > 100 and id < 200
 
Share this answer
 
SQL
select count(*) + 100 from (
 select ROW_NUMBER() over(order by pk)id,* from #leave
  ) a where id > 100






try this.:)
 
Share this answer
 
select count(*) , trunc(a.Date),d.cita
from dbdev.sub a , dbdev.num b, dbdev.dis c , dbdev.cit d
where a.sen=b.mo
and b.di =c.id
and c.id =d.id
and a.date >=trunc(to_Date('01/01/2011','dd/mm/yyyy'))
and a.date <trunc(sysdate)>

group by trunc(a.Date) ,d.cita
order by trunc(a.Date)


This is my query and the count will show all the numbers from 0 and above , but my point is to show only above 100 not from 0 and above !!!

and BTW thanks alot for your ideas am really appreciate that , but my problem did not solve yet !

Best regards
Ahmed
 
Share this answer
 
Hi Ahmed,

If you meant IDs greater than 100 then you should add another condition to your where clauses by using an and keyword (and its very obvious and I'm sure that you are aware of that) :

SQL
select count(*) , trunc(a.Date),d.cita
from dbdev.sub a , dbdev.num b, dbdev.dis c , dbdev.cit d
where a.sen=b.mo
and b.di =c.id
and c.id =d.id
and a.date >=trunc(to_Date('01/01/2011','dd/mm/yyyy'))
and a.date <trunc(sysdate)>

and a.id >= 100

group by trunc(a.Date) ,d.cita
order by trunc(a.Date)



But I guess that you want all counts which are greater than 100. in that case you should use HAVING clause :
SQL
select count(*) , trunc(a.Date),d.cita
from dbdev.sub a , dbdev.num b, dbdev.dis c , dbdev.cit d
where a.sen=b.mo
and b.di =c.id
and c.id =d.id
and a.date >=trunc(to_Date('01/01/2011','dd/mm/yyyy'))
and a.date <trunc(sysdate)>

group by trunc(a.Date) ,d.cita
having count(*)>=100
order by trunc(a.Date)



Hope it helps.
 
Share this answer
 
Comments
Ahmed k dema 4-Dec-11 4:22am    
Thank you Very much Amir , my problem was solved by this solution:
"" Having count(*)>=100 ""

Best regards :D
Amir Mahfoozi 4-Dec-11 4:30am    
You're welcome ;)
well ,
it will take the values from 99 and above , but my point is to begin the count from 100 not 0 !!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900