If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Need a Query to update ranks....

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-04, 06:28
maven maven is offline
Registered User
 
Join Date: Nov 2004
Posts: 17
Need a Query to update ranks....

Hi ,

I have a table with data like below.

IP - service - hit -rank1-rank2
1.1.1.1 - Udp - 400
1.1.1.1 - Tcp - 300
2.2.2.2 - Udp - 100
2.2.2.2 - Tcp - 150

by default rank1, rank2 will be null. Need to update ranks and resulted table as looks like....

IP - service - hit -rank1-rank2
1.1.1.1 - Udp - 400 - 1 - 1
1.1.1.1 - Tcp - 300 - 1 - 2
2.2.2.2 - Udp - 100 - 2 - 2
2.2.2.2 - Tcp - 150 - 2 - 1

rank1 should be calculated like ....
sum(hit) from table group by ip.

and rank2 should be calculated like...

sum(hit) from table group by service where ip=ip.

Rank1 will be max hits to one particular ip, no matter whatever service is.

Rank2 will be max of hits to one particular service, for one ip.

Please help me to write update query for above. Its little urgent for me.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 11-23-04, 09:08
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
want me to try? you will have to create a couple of temp tables

hmm, lemme see, i've got that code around here somewhere
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-23-04, 09:51
maven maven is offline
Registered User
 
Join Date: Nov 2004
Posts: 17
please help me to get code

Hi,

can you please help me to get that code or guide me how to proceed further. As its little urgent for me, tried in different ways, but nothing was worked out till.

Thanks.
Reply With Quote
  #4 (permalink)  
Old 11-23-04, 10:11
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On