我将在我的"测验"中选择最高的结果。表中有5种类型的数据:
quizid,userid,quizdate,result,topicid
1 JAKE 1/7/2015 60 1
2 JAKE 1/7/2015 80 1
3 JAKE 1/7/2015 100 2
我想只显示一次主题和用户最高分。
它只显示用户的第一高分,用户再次重新测验后不会显示最高分。
示例:Userid JAKE在测验1中第一次进行测验时有60分,当他重做测验1并得到80分时,它仍然在表中显示60马克。
Select userid,topicid, MAX(result) as result
FROM quiz GROUP BY userid, topicid
ORDER BY result desc
最终结果应该是JAKE在主题1中显示80,但我的结果是
1 JAKE 1/7/2015 60 1
3 JAKE 1/7/2015 100 2
答案 0 :(得分:0)
select * from (Select userid,topicid, result as result
FROM quiz ORDER BY result desc) as t GROUP BY t.userid, t.topicid
答案 1 :(得分:0)
尝试以下,
public partial class UserControl1 : UserControl, INotifyPropertyChanged
{
private bool isShowHideVisible;
public bool IsShowHideVisible
{
get { return isShowHideVisible; }
set
{
if(isShowHideVisible!=value)
{
isShowHideVisible = value;
OnPropertyChange("IsShowHideVisible");
}
}
}
public UserControl1()
{
InitializeComponent();
this.DataContext=this;
}
private void OnPropertyChange(string pPropertyName)
{
if(PropertyChanged!=null)
{
PropertyChanged(this, new PropertyChangedEventArgs(pPropertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}