Rouven: Group By

Beitrag lesen

Hello,

$rstops = mysql_query("SELECT * FROM aw_counter_ref GROUP BY 'referer' DESC LIMIT 30");

sowas kann auch nur MySQL durchgehen lassen. Zunächst mal: Ein SELECT-Statement mit GROUP BY-Anweisung darf im SELECT-Teil nur zwei Arten von Spalten enthalten:

  1. solche nach denen gruppiert wurde (in deinem Fall - ähm - na ja, du hast referer gemeint und eigentlich "referer" geschrieben)
  2. solche die aus Aggregationen entstanden sind.

Am Besten nennst du uns mal kurz deine Tabellenstruktur, wahrscheinlich suchst du etwas wie
SELECT referer, COUNT(referer) AS anzahl
FROM aw_counter_ref
GROUP BY referer
ORDER BY anzahl DESC

MfG
Rouven

--
-------------------
Computer programming is tremendous fun. Like music, it is a skill that derives from an unknown blend of innate talent and constant practice. Like drawing, it can be shaped to a variety of ends: commercial, artistic, and pure entertainment. Programmers have a well-deserved reputation for working long hours but are rarely credited with being driven by creative fevers. Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination, but because their imagination reveals worlds that others cannot see. -- Larry OBrien and Bruce Eckel in Thinking in C#