对呀!
他的表结构是这样的!
字段名 类型 长度
jd_id int 4 0
jd_startdate datetime 8 0
jd_enddate datetime 8 0
jd_start bit 1 1
jd_select bit 1 1
他的表结构是这样的!
字段名 类型 长度
jd_id int 4 0
jd_startdate datetime 8 0
jd_enddate datetime 8 0
jd_start bit 1 1
jd_select bit 1 1
解决方案 »
- sql2008中,如何同时复制多个表的表结构?
- 小弟不才有个数据库查询的问题请教各位大大
- 求一条关于筛选取最大记录的sql语句 谢谢各位!
- 求SQL 靠近15分钟函数
- 一道 事务管理 超级弱智的问题,望达人指教一二!在线等啊,都进来看看,很简单的!
- windows身份登陆数据库的连接字符怎么写?
- 写了一个多小时代码。写不下去了。请大家帮个忙想个办法!
- 为什么我装了VS.NET后,SQL SERVER就装不上了?
- 大家帮助我好吗,很急...................
- MS SQL求教存储过程参数里包含另一个参数要怎么处理
- 关于数据库备份的问题,急急急!!在线等待
- 一个简单的select语句
sum(case when f.jd_select=0 then jf_grades
else jf_yesno end)
from
tb_judgefile a,
tb_classcourse b,
tb_class c,
tb_course d,
tb_teacher e,
tb_judgedate f
where a.jt_tc_id=b.jt_tc_id
and b.cla_id=c.cla_id
and b.cou_id=d.cou_id
and b.tea_id=e.tea_id
group by a.sgs_id,c.cla_name,d.cou_name,e.tea_name,
select a.sgs_id,c.cla_name,d.cou_name,e.tea_name,
sum(case when f.jd_select=0 then jf_grades
else jf_yesno*1 end)
from
tb_judgefile a,
tb_classcourse b,
tb_class c,
tb_course d,
tb_teacher e,
tb_judgedate f
where a.jt_tc_id=b.jt_tc_id
and b.cla_id=c.cla_id
and b.cou_id=d.cou_id
and b.tea_id=e.tea_id
group by a.sgs_id,c.cla_name,d.cou_name,e.tea_name
sum(case when f.jd_select=0
then jf_grades
else (case when jf_yesno is null
then 0
else 1
end)
end)
from
tb_judgefile a,
tb_classcourse b,
tb_class c,
tb_course d,
tb_teacher e,
tb_judgedate f
where a.jt_tc_id=b.jt_tc_id
and b.cla_id=c.cla_id
and b.cou_id=d.cou_id
and b.tea_id=e.tea_id
group by a.sgs_id,c.cla_name,d.cou_name,e.tea_name
我说照这样分组下去的话就没有组可言了耶!因为各是一条记录!
select a.sgs_id,max(c.cla_name),max(d.cou_name),e.tea_name,
sum(case when f.jd_select=0
then jf_grades
else (case when jf_yesno is null
then 0
else 1
end)
end)
from
tb_judgefile a,
tb_classcourse b,
tb_class c,
tb_course d,
tb_teacher e,
tb_judgedate f
where a.jt_tc_id=b.jt_tc_id
and b.cla_id=c.cla_id
and b.cou_id=d.cou_id
and b.tea_id=e.tea_id
group by a.sgs_id,c.cla_name1.如果:d.cou_name,e.tea_name不要:
select a.sgs_id,c.cla_name,
sum(case when f.jd_select=0
then jf_grades
else (case when jf_yesno is null
then 0
else 1
end)
end)
from
tb_judgefile a,
tb_classcourse b,
tb_class c,
tb_judgedate f
where a.jt_tc_id=b.jt_tc_id
and b.cla_id=c.cla_id
group by a.sgs_id,c.cla_name
呀?
如果要名称,分组NAME只有取最大或最小的了
取他们的名字就没有取了!呵呵,高手你是从哪方面看出可以不要呢?那分组我看了一下帮助.用了group by 就只可以用聚簇函数了!