Re: [SQL ] 兩個SQL語法要合併寫在一起
以下是我胡亂試出來的,請參考...
string sqlStr = "select EM.StuName ,
sum(datediff(hh,SP.StartTime,SP.EndTime) as Times, ";
sqlStr += "sum(datediff(hh,SP.StartTime,SP.EndTime))*5400 as Bonus ";
sqlStr += "from Student as EM left join Spell as SP ";
sqlStr += "on SP.SpellStuID in ";
sqlStr += "( ";
sqlStr += " select SP2.SpellStuID ";
sqlStr += " from Spell as SP2 ";
sqlStr += " where EM.StuID = SP2.SpellStuID and YearMonth = '" + YearMonth
+"' ";
sqlStr += ") ";
sqlStr += "where EM.UnitID = '" + ClassID.Substring(0, 3) + "' ";
sqlStr += "group by EM.StuName ";
頭好痛...... ><"
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.137.101.19
討論串 (同標題文章)
完整討論串 (本文為第 8 之 9 篇):