我需要一些MySQL SELECT語句的幫助。不幸的是,這種說法無法正常工作。它似乎根據學校名稱的字母順序排列,而不是reading_percent_proficient_and_advanced。我應該如何解決它?MySQL加入問題
SET @rank=0;
SELECT @rank:[email protected]+1 as rank,
sy.formatted_school_name,
FLOOR(d.reading_percent_proficient + d.reading_percent_advanced) AS reading_percent_proficient_and_advanced
FROM d_test_scores AS d,
sy_2010_2011_school_type AS sy
WHERE sy.school_id = d.school_id
AND sy.school_group = 'public school'
AND sy.school_type ='elementary'
ORDER BY reading_percent_proficient_and_advanced DESC
如果我拿出的加入,那麼這種說法給了我正確的排名(但我沒有那麼學校名稱):
SET @rank=0;
SELECT @rank:[email protected]+1 as rank,
d.school_id,
FLOOR(d.reading_percent_proficient + d.reading_percent_advanced) AS reading_percent_proficient_and_advanced
FROM d_test_scores AS d
ORDER BY reading_percent_proficient_and_advanced DESC;
什麼是我加入的問題?
寫入的查詢應該可以工作。你能給出一些樣本數據和每個查詢的結果嗎? –