使用sqlite3,我在“学生”表中有一列“成绩”,我希望获得在考试中得分超过80的学生比例。我怎么得到的?我可以select count(*) from students and then select count(*) from students where score>80
,但是如何在一个语句中得到该比例呢?
答案 0 :(得分:1)
这是执行此操作的简单方法:
import React from 'react';
import { Select, MenuItem } from '@material-ui/core/Select';
export default class IATACodesSelect extends React.Component {
constructor(props) {
super(props);
this.state = {
iata: []
}
this.changeIATAState = this.changeIATAState.bind(this);
this.renderIATACodes = this.renderIATACodes.bind(this);
}
componentWillMount() {
this.changeIATAState();
}
changeIATAState = () => {
this.setState({iata: this.getIATACodes});
}
getIATACodes = () => {
return JSON.parse("../../assets/iata-codes.json");
}
renderIATACodes = () => {
return this.state.iata.map(data =>
<MenuItem key={data.response.code}>{data.response.name}</MenuItem>
)
}
render() {
return(
<Select>
{this.renderIATACodes()}
</Select>
);
}
}
这只是整个表的有条件平均值,计算80分以上的学生人数,然后根据学生总数进行归一化。