All pastes #564807 Raw Edit

Someone

public text v1 · immutable
#564807 ·published 2007-06-13 18:53 UTC
rendered paste body
What I want is the (SELECT ) to be run with the value of each GROUP.. it doesn't seem to do that now, what am i doing wrong?

SELECT
    MAX(ksc.computerLastLogin) max,
    (SELECT MIN(usageWhen) FROM KSUsage
          WHERE usageEvent = 16
          AND usageComputerID = ksc.computerID) min,
    ksc.computerDivisionID id,
    ksd.divisionName name
  FROM KSComputers ksc
      JOIN KSComputerDivisions ksd ON ksc.computerDivisionID = ksd.divisionID
  WHERE ksc.computerDivisionID != 0
  GROUP BY ksc.computerDivisionID
  ORDER BY name;