help - ordering

Thread Solved

Join Date: Oct 2009
Posts: 24
Reputation: gpss is an unknown quantity at this point 
Solved Threads: 0
gpss gpss is offline Offline
Newbie Poster

help - ordering

 
0
  #1
Oct 21st, 2009
Hello! I need some help please..

i searched a lot, and tried everything... can someone help me please..

here's the deal:

i have this select:

  1. SELECT *
  2. FROM localizacao, cliente, dispositivo
  3. WHERE disp_id = clien_disp_id AND disp_id = local_disp_id
  4. ORDER BY local_id desc

it's output:
http://i.imagehost.org/0746/tabela.jpg

but what i really want is:

i want to select my client's, but where local_id is the last id i receive.. but i don't wanna show repetitive client's, i just want to show the last local_id for each client....
i want like to show only this ones: http://i.imagehost.org/0883/tabela2.jpg in the red circle

you know what i mean?
it's like two order by's but not showing repetitive client's... i tried distinct... but maybe im making it wrong..

help :s

thanks a lot
Last edited by gpss; Oct 21st, 2009 at 12:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 21
Reputation: spthorn is an unknown quantity at this point 
Solved Threads: 5
spthorn's Avatar
spthorn spthorn is offline Offline
Newbie Poster
 
0
  #2
Oct 22nd, 2009
This was a good exercise! This code will do what you want:
  1. SELECT #localizacao.*, #cliente.*, #dispositivo.*
  2. FROM #dispositivo
  3. JOIN #localizacao on #localizacao.local_disp_id = #dispositivo.disp_id
  4. JOIN #cliente on #cliente.clien_disp_id = #dispositivo.disp_id
  5. JOIN (
  6. SELECT max(local_id) as localid, clien_id, local_disp_id
  7. FROM #localizacao, #cliente, #dispositivo
  8. WHERE disp_id = clien_disp_id AND disp_id = local_disp_id
  9. GROUP BY local_disp_id, clien_id
  10. ) as a
  11. on a.localid=#localizacao.local_id and a.clien_id=#cliente.clien_id and a.local_disp_id=#dispositivo.disp_id
All opinions 100% correct. Or your money back.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 24
Reputation: gpss is an unknown quantity at this point 
Solved Threads: 0
gpss gpss is offline Offline
Newbie Poster
 
0
  #3
Oct 22nd, 2009
Thank you so mutch spthorn!!!!!!

THANK YOU MY FRIEND, THANKS FOR YOUR HELP, IT WORKED!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC