博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
坑爹的sql,好不容易写成这样,谁知道,必须得有userid参照值,否则就报错,求解救...
阅读量:6430 次
发布时间:2019-06-23

本文共 3203 字,大约阅读时间需要 10 分钟。

select (select RowNum from(select row_number()over(order by Achievement_Content desc) as RowNum,* from FM_Achievement table1 where table1.Achievement_ExamId=FM_Achievement.Achievement_ExamIdand table1.Achievement_SubjectId=FM_Achievement.Achievement_SubjectId and table1.Sid=FM_Achievement.Sid) table2 where FM_Achievement.Achievement_UserId=table2.Achievement_UserId) as gradenum,(select RowNum from(select row_number()over(order by Achievement_Content desc) as RowNum,* from FM_Achievement table1 where table1.Achievement_ExamId=FM_Achievement.Achievement_ExamIdand table1.Achievement_SubjectId=FM_Achievement.Achievement_SubjectId and table1.Sid=FM_Achievement.Sid and table1.Achievement_Class=FM_Achievement.Achievement_Class) table2 where FM_Achievement.Achievement_UserId=table2.Achievement_UserId) as classnum,(select MAX(Achievement_Content) from(select row_number()over(order by Achievement_Content desc) as RowNum,* from FM_Achievement table1 where table1.Achievement_ExamId=FM_Achievement.Achievement_ExamIdand table1.Achievement_SubjectId=FM_Achievement.Achievement_SubjectId and table1.Sid=FM_Achievement.Sid ) table2 ) as gradehig,(select MAX(Achievement_Content) from(select row_number()over(order by Achievement_Content desc) as RowNum,* from FM_Achievement table1 where table1.Achievement_ExamId=FM_Achievement.Achievement_ExamIdand table1.Achievement_SubjectId=FM_Achievement.Achievement_SubjectId and table1.Sid=FM_Achievement.Sid and table1.Achievement_Class=FM_Achievement.Achievement_Class) table2) as classhig,(select avg(Achievement_Content) from(select row_number()over(order by Achievement_Content desc) as RowNum,* from FM_Achievement table1 where table1.Achievement_ExamId=FM_Achievement.Achievement_ExamIdand table1.Achievement_SubjectId=FM_Achievement.Achievement_SubjectId and table1.Sid=FM_Achievement.Sid ) table2) as gradeavg,(select avg(Achievement_Content) from(select row_number()over(order by Achievement_Content desc) as RowNum,* from FM_Achievement table1 where table1.Achievement_ExamId=FM_Achievement.Achievement_ExamIdand table1.Achievement_SubjectId=FM_Achievement.Achievement_SubjectId and table1.Sid=FM_Achievement.Sid and table1.Achievement_Class=FM_Achievement.Achievement_Class) table2) as classavg,(select (Grade_Name+Class_Name) as name1 from dbo.FM_GradeClass where FM_GradeClass.Grade_Id=FM_Achievement.Achievement_Class) as GradeClassName,(select Exam_Name from dbo.FM_Exam where FM_Exam.Exam_Id=FM_Achievement.Achievement_ExamId) as ExamName,(select ExamTotalNum from FM_Exam where FM_Exam.Exam_Id=FM_Achievement.Achievement_ExamId) as ExamTotalNum,(select ExamClassNum from dbo.FM_ExamAll where FM_ExamAll.Exam_Id=FM_Achievement.Achievement_ExamId and FM_ExamAll.ExamAll_GradeClassCode=FM_Achievement.Achievement_Class and FM_ExamAll.ExamAll_Subjectid=FM_Achievement.Achievement_SubjectId) as ExamClassNum,(select Subject_Name from dbo.FM_Subject where dbo.FM_Subject.Subject_Id=FM_Achievement.Achievement_SubjectId) as SubjectName,Achievement_UserId,Achievement_UserName,Achievement_Contentfrom FM_Achievement where Achievement_UserId='100706010120' and Achievement_SubjectId=4483

 

转载于:https://www.cnblogs.com/29ing/archive/2013/04/13/3018721.html

你可能感兴趣的文章
trove 基于 centos7 制作 mysql5.6 镜像
查看>>
结合i节点和数据块分析linux中软链接和硬链接的区别
查看>>
Heartbeat crm的配置
查看>>
Stream
查看>>
我的友情链接
查看>>
Windows Server 2012_Install_Guide
查看>>
ISA Server搭建站点对站点×××
查看>>
我的友情链接
查看>>
超大规模数据中心:给我一个用整机柜的理由先
查看>>
Cacti——安装
查看>>
执行命令取出linux中eth0的IP地址
查看>>
小强系列之大话移动测试
查看>>
java学习(二)--excel导出
查看>>
微信小程序--helloworld
查看>>
6.17 dokcer(二)安装与卸载Compose
查看>>
Apache Storm技术实战之1 -- WordCountTopology
查看>>
关于寻路
查看>>
CRUD全栈式编程架构之控制器的设计
查看>>
python常用内建模块(五)
查看>>
你为什么有那么多时间写博客?
查看>>