MySQL Forums
Forum List  »  German

Re: GREATEST / MAX von berechneten Spalten
Posted by: Thomas Wiedmann
Date: April 16, 2012 06:38AM

Hallo Mark,
ganz sicher bin ich mir bei dem Ergebnis auch nicht. Vielleicht könntest du ein kleines Nachvollziehbares Beispiel aufbauen.
Innerhalb einer Gruppe "id_company,resultDate" werden hier drei Ergebnisse geliefert

..
  FROM ( SELECT 
          id_company,
          resultDate, 
          MAX(L) AS L,
          MAX(L * 1734.90 * 0.03225807) AS LV,
          MAX((L * 1734.90 * 0.03225807) * factor / 31) AS LS
          FROM results 
         WHERE resultDate <= '2011-12-15' AND resultDate > ('2011-12-15'- INTERVAL 3 DAY) 
        GROUP BY id_company,resultDate 
       ) max_l
...

1.) L = das MAX(L) in dieser Gruppe
2.) L*x = das MAX(L) * x in dieser Gruppe mal einer Konstante
3.) L*x*faktor = das MAX(L*faktor) * x in dieser Gruppe mal einer Konstante

Diese Ergebnisse 2. und 3. müssen NICHT aus der selben Zeile der Tabelle stammen, da bei 3. erst multipliziert wird und dann MAX() berechnet wird.

Das Beste wird sein, ein kleines nachvollziehbares Beispiel aufzubauen.

Grüße
Thomas

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.