急!!!请各位大神帮忙看看。

yang_lawrence 2013-01-28 11:43:00
select accountName,accountId,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as addresource,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as updateresource,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=3 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as deleteresource,
(select count(logId) from syslog where objectTypeId=2015 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as updatejianli,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=5 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as lookresource,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=6 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shangchuanresourcefujian,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=7 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as xiazairesourcefujian,
(select count(logId) from syslog where objectTypeId=2010 and eventTypeId=8 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shuanchuresourcefujian,
(select count(logId) from syslog where objectTypeId=2030 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as addresourcepingyu,
(select count(logId) from syslog where objectTypeId=2040 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as udpateresourcebeijingdiaocha,
(select count(logId) from syslog where objectTypeId=2050 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as lookresourcemingganxinxi,
(select count(logId) from syslog where objectTypeId=2050 and eventTypeId=5 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shenpiresourcemingganxinxi,
(select count(logId) from syslog where objectTypeId=2080 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as addresourcexunfang,
(select count(logId) from syslog where objectTypeId=2080 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as updateresourcexunfang,
(select count(logId) from syslog where objectTypeId=2080 and eventTypeId=3 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shanchuresourcexunfang,
(select count(logId) from syslog where objectTypeId=2090 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as addresourcexunfangpingyu,
(select COUNT(Distinct resCommentsId) from rescomments rt where (select createAccId from resource where resourceId=rt.resourceId)!= rt.commentAccId and rt.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59' and rt.commentAccId=sysaccount.accountId)as addxunfangpingyufeibenren,
(select count(logId) from syslog where objectTypeId=20100 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as addmubiaogongsi,
(select count(logId) from syslog where objectTypeId=20100 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as updatemubiaogongsi,
(select count(logId) from syslog where objectTypeId=20100 and eventTypeId=3 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shanchumubiaogongsi,
(select count(logId) from syslog where objectTypeId=20110 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shangchuanmobiaogongsifujian,
(select count(logId) from syslog where objectTypeId=20110 and eventTypeId=6 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as xiazaimubiaogongsifujian,
(select count(logId) from syslog where objectTypeId=20100 and eventTypeId=7 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shanchumobiaogongsifujian,
(select count(logId) from syslog where objectTypeId=820100 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as zhuanhuaxianren,
(select count(logId) from syslog where objectTypeId=820100 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as upatexianren,
(select count(logId) from syslog where objectTypeId=820100 and eventTypeId=3 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shanchuxianren,
(select count(logId) from syslog where objectTypeId=820110 and eventTypeId=2 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as shenqingzhuanhuaxianren,
(select count(logId) from syslog where objectTypeId=820110 and eventTypeId=4 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as pizhunzhuanhuaxianren,
(select count(logId) from syslog where objectTypeId=820110 and eventTypeId=3 and syslog.accountId=sysaccount.accountId and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59')as jujuezhuanhuaxianrenshenqin
from dbo.sysaccount where status not in(2,3) order by accountName asc


请各位大神帮忙看看这个查询有什么问题?查询半天都不出结果。急求!!!
...全文
179 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sd722522 2013-01-29
  • 打赏
  • 举报
回复
你这不慢就怪了
昵称被占用了 2013-01-28
  • 打赏
  • 举报
回复
select sysaccount.accountName,sysaccount.accountId, sum(case when syslog.objectTypeId=2010 and syslog.eventTypeId=2 and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59' then 1 else 0 end) as addresource, sum(case when syslog.objectTypeId=2010 and syslog.eventTypeId=4 and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23:59:59' then 1 else 0 end) as updateresource, ... from sysaccount ,syslog where sysaccount.status not in(2,3) and syslog.accountId=sysaccount.accountId group by sysaccount.accountName,sysaccount.accountId order by sysaccount.accountName asc
昵称被占用了 2013-01-28
  • 打赏
  • 举报
回复
这么多子查询当然慢了
yang_lawrence 2013-01-28
  • 打赏
  • 举报
回复
引用 2 楼 Haiwer 的回复:
select sysaccount.accountName,sysaccount.accountId, sum(case when syslog.objectTypeId=2010 and syslog.eventTypeId=2 and syslog.createTime between '2012-12-28 00:00:00' and '2013-01-28 23……
但是用你的方法也是很慢的。
内容概要:本文介绍了一种基于多目标粒子群算法(MOPSO)的微电网优化调度模型,综合考虑风能、光伏、储能系统、柴油发电机、燃气轮机以及与主电网之间的能量交互等多种分布式能源的协同运行。通过构建以运行成本最小化、碳排放最低化和系统可靠性最优化为目标的多目标优化模型,利用Matlab平台实现MOPSO算法求解,完成对微电网在不同运行场景下的能量管理与调度方案优化。该模型能够有效平衡经济性与环保性之间的关系,适用于含多类型分布式电源的复杂微电网系统,具有较强的工程应用价值和科研参考意义; 适合人群:具备一定电力系统基础知识和Matlab编程能力的研究生、科研人员及工程技术人员,尤其适合从事微电网、智能电网、综合能源系统、可再生能源集成与优化调度等领域研究的专业人士; 使用场景及目标:①用于多能源耦合微电网系统的协同优化调度研究;②支持多目标智能优化算法在能源系统中的建模与求解实践,帮助用户掌握MOPSO在实际工程问题中的应用方法;③为学术论文复现、毕业设计、科研项目开发提供完整的代码实例与技术支撑; 阅读建议:建议读者结合Matlab代码与理论文档,深入理解目标函数构建、约束条件处理及Pareto最优解集生成机制,重点关注算法参数设置、多目标权衡分析与结果可视化,并可通过调整能源配置或引入新约束进行二次开发与创新研究。

22,296

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧