Wednesday, March 7, 2012

complex SQL query

http://img100.imageshack.us/my.php?image=sqloi8.png

(please refer this first before proceeding)

I want a SQL query that satisfies the following results:-

Question# I want to count the rows where the client + server IP remain same over a particular # of entries like 10,20 and etc.
E.g 1-4 is a pattern where both client and server ip have remain same. I want a count of that.

Sub-Question# Secondly, i wanna retrieve only the most recent record .The pattern which was prevalent in the time b/w 12:22 to 1:00 is irrelevent i want the next query to execute with the current time.

I used SQLdata reader but it is being unable to retrieve
me the exact count i require due to inherent restriction that comes
with the scope of this method. I cannot use it DataGrid because
im using a command application(dos etc).

Please help me get over this..Thanks.I am not in habbit of opening each and every link that i come across in net.|||

Quote:

Originally Posted by debasisdas

I am not in habbit of opening each and every link that i come across in net.


u must be kidding right.... i have posted the same link to other forums noone was probably as pessimistic as your are.|||

Quote:

Originally Posted by zonar00

http://img100.imageshack.us/my.php?image=sqloi8.png

(please refer this first before proceeding)

I want a SQL query that satisfies the following results:-

Question# I want to count the rows where the client + server IP remain same over a particular # of entries like 10,20 and etc.
E.g 1-4 is a pattern where both client and server ip have remain same. I want a count of that.

Sub-Question# Secondly, i wanna retrieve only the most recent record .The pattern which was prevalent in the time b/w 12:22 to 1:00 is irrelevent i want the next query to execute with the current time.

I used SQLdata reader but it is being unable to retrieve
me the exact count i require due to inherent restriction that comes
with the scope of this method. I cannot use it DataGrid because
im using a command application(dos etc).

Please help me get over this..Thanks.


Would it be possible to modify the data structure? I mean the first thing I would need is a running count column for each row. Do you use 2005 or 2000? (2005 has a new RANK() function that can be used to this end w/o having to modify the data structure.) BTW: Does "Time" contain dates as well? (So that we can handle wrap-arounds.)

Then: I suppose from the nature of the data that ClientIP/ServerIP combinations can "come back" at a later time (i.e. the same IPs can be assigned after a while -- whereas in the meantime either or both are different). I also assume that separate counts are needed for each such run. Please, verify these assumptions.

No comments:

Post a Comment