mysql對結果計算 MYSQL計算結果

2021-10-18 02:14:36 字數 853 閱讀 2326

我正在

mysql 5.0中構建乙個查詢來計算學生的學期成績.初始表(studentitemgrades)包含將用於計算最終成績的作業列表等.每項作業都有乙個possiblescore,grade和weight.計算應對所有類似加權的專案進行分組,並根據分配到期的日期範圍提供sum(grade)/ sum(possiblescore).我遇到的問題是所有個別加權等級的最終總和.例如,結果目前產生以下結果:

coursescheduleid sdbid assigneddate duedate weight weightedgrade

1 519 2010-08-26 2010-08-30 10 0.0783333333333333

1 519 2010-09-01 2010-09-03 20 0.176

1 519 2010-09-01 2010-09-10 70 0.574

來自查詢:

select coursescheduleid, sdbid, assigneddate, duedate, weight,

((sum(grade)/sum(possiblescore))*(weight/100)) as weightedgrade

from studentitemgrades

where duedate>='2010-08-23'

and duedate<='2010-09-10'

and coursescheduleid=1

and sdbid=519

and status>0

group by weight

問題:我現在如何將weighedgrade輸出中的三個結果相加?順便說一下,這是計算特定校園所有課程所有成績的更大查詢的一部分.

mysql 對結果重新編號 為MySQL結果行編號

我有乙個像下面這樣的mysql結果集 id name 1 abc 1 abc 2 xyz 2 xyz 3 pqr 現在,我需要修改結果集,以便如下所示 id name 1 abc 1 1 abc 2 2 xyz 1 2 xyz 2 3 pqr 總結是我需要對結果集中的名稱列進行編號,並且該編號僅適用...

MySQL對查詢結果排序

從表中查詢出來的資料,可能是無序的,或者其排列順序表示使用者期望的 使用order by對查詢結果進行排序 select 欄位名1,欄位名2,from 表名 order by 欄位名1 asc desc 欄位名2 asc desc 指定的欄位名1 欄位名2,是對查詢結果排序的依據 引數asc,表示按...

MySQL對查詢結果排序

mysql對查詢結果排序,從表中查詢出來的資料,可能是無序的,或者其排列順序表示使用者期望的。使用order by對查詢結果進行排序 select 欄位名1,欄位名2,from 表名 order by 欄位名1 asc desc 欄位名2 asc desc 指定的欄位名1 欄位名2,是對查詢結果排序...