Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE problem

Status
Not open for further replies.

Baukep

Programmer
Sep 28, 2006
44
NL
I have the following query. It gives me every time the most recent standings in this seisons competition.
Is there a way to update another table with the results of this query?

The code should be (I think):
UPDATE standen
SET speler = speler, jaarweek = MAX(JaarWeek), stand = Stand


SELECT therealselect.*,@row_index:=@row_index+1 Stand from (
SELECT w_seizoen AS Seizoen
, MAX(w_datum)
, speler
, MAX(JaarWeek)
, COUNT(w_wnr) AS "Gespeeld"
, SUM(berpunten) AS "Tot. punten"
, SUM(berpunten)/COUNT(w_wnr) AS Winstperc
, ROUND(SUM(car)/SUM(w_brtn),4)- ROUND(temaken/25,4) AS Moyenne
, MAX(HSerie)/temaken AS "HSerie (%%)"
FROM resultaten
GROUP BY speler
ORDER BY Winstperc DESC, Moyenne DESC
) therealselect,(SELECT @row_index:=0) ri

One more problem: The MAX(JaarWeek) gives me the max for every speler. It should be the max from the table (view) resultaten. I think I have to use a variable but don't know where and how (the row-index problem was solved thanks to Feherke)

Thanks in advance

Bauke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top