Home » SQL & PL/SQL » SQL & PL/SQL » counting occurances
counting occurances [message #217340] Thu, 01 February 2007 14:46 Go to next message
shawn59
Messages: 3
Registered: February 2007
Junior Member
hi all,
Im having trouble writing part of a program. I need to count the number of values there are in a table that fall withen a range of an inputed value. eg. the range is +10 km/h and -10 km/h of the speed inputed. I need to know how many values there are withen that range if the user enters a speed.
Re: counting occurances [message #217341 is a reply to message #217340] Thu, 01 February 2007 14:48 Go to previous messageGo to next message
BlackSwan
Messages: 25041
Registered: January 2009
Location: SoCal
Senior Member
>I'm having trouble writing part of a program.
What troubles & what part works now?
Re: counting occurances [message #217343 is a reply to message #217340] Thu, 01 February 2007 14:56 Go to previous messageGo to next message
shawn59
Messages: 3
Registered: February 2007
Junior Member
the trouble is that I dont know how to do it..
I haven't tried putting it all togeather yet but I think the rest is fine for now, I just dont know how to do what I described above. any help is appreciated
Re: counting occurances [message #217346 is a reply to message #217340] Thu, 01 February 2007 15:02 Go to previous messageGo to next message
BlackSwan
Messages: 25041
Registered: January 2009
Location: SoCal
Senior Member
> but I think the rest is fine for now,
I agree.
In the future you might pay closer attention in class.
If we do your home work for you, how do you expect to learn anything?
Re: counting occurances [message #217348 is a reply to message #217346] Thu, 01 February 2007 15:09 Go to previous messageGo to next message
shawn59
Messages: 3
Registered: February 2007
Junior Member
haha. Im in the process of learning how to do it on my own. ok then how woud I learn such a thing..
Re: counting occurances [message #217351 is a reply to message #217340] Thu, 01 February 2007 15:17 Go to previous message
Ericle
Messages: 44
Registered: April 2006
Location: United States of America ...
Member

Assuming there is a column in the table that stores the km/h, your code would look something like this:

select count(*)
  from a_table
 where speed_column between :input_speed - 10 and :input_speed + 10

[Updated on: Thu, 01 February 2007 15:26]

Report message to a moderator

Previous Topic: Duration between two times
Next Topic: How to install sql*loader in ubuntu
Goto Forum:
  


Current Time: Tue Dec 06 08:52:31 CST 2016

Total time taken to generate the page: 0.10287 seconds