File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Urgent Help in Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Urgent Help in Query" Watch "Urgent Help in Query" New topic

Urgent Help in Query

Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
I have the table like following

Time/Date Close Average

1 100 NO
2 200 No
3 129.39 No
4 200 No
5 129.39 No
6 100 NO
7 200 No
8 129.39 No
9 100 NO
10 200 No
11 123 avg(close(1 to 10)/10)
12 234 avg(close(2 to 11)/10)has to display
13 231 avg(close(3 to 12)/10)has to display
14 . ...
15 . ...and so on

where ever i want to find the avg ,I have to take the 10 closes beofre the curent value
how can i write that query

please help me wrinting this query in java
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Why is this urgent?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

I think this may be one of the first times I've seen "...and so on" and had no idea what the person was talking about.

[OCA 8 Book] [Blog]
Kevin Smither
Ranch Hand

Joined: Oct 22, 2007
Posts: 30
you want to write the query in Java? What do you mean by that? I am assuming this is a database query?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33117

First of all, you want to write the query in SQL. Java JDBC just lets you call SQL. The query is still written in SQL.

I don't follow what you are trying to do either. Can you describe the desired output a bit more.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Urgent Help in Query
It's not a secret anymore!