sql存储过程,查询一个时间段内的挂号人数,金额,按照课科室统计,基本代码怎么写的,初学者不太明白
createprocedureusp_gh_rcje@ksrqut_rq16,@jsrqut_rq8assetnocountonselectsum(a.xmsl)as挂号...
create procedure usp_gh_rcje
@ksrq ut_rq16,
@jsrq ut_rq8
as
set nocount on select sum(a.xmsl) as 挂号人数 from GH_GHMXK as a,GH_GHZDK as b
where a.xh=b.xh and b.ghrq between '20160701' and '20160720' and b.ksdm='3201'
select sum(a.zje) as 总金额 from SF_BRJSK as a,GH_GHZDK as b
where a.blh = b.blh and b.ghrq between '20160701' and '20160720' and a.ksdm= '3201'
select distinct * from GH_GHZDK as GH_GHK
where ksdm='3201'
这是我写的,但是老师说不对,让我再修改 展开
@ksrq ut_rq16,
@jsrq ut_rq8
as
set nocount on select sum(a.xmsl) as 挂号人数 from GH_GHMXK as a,GH_GHZDK as b
where a.xh=b.xh and b.ghrq between '20160701' and '20160720' and b.ksdm='3201'
select sum(a.zje) as 总金额 from SF_BRJSK as a,GH_GHZDK as b
where a.blh = b.blh and b.ghrq between '20160701' and '20160720' and a.ksdm= '3201'
select distinct * from GH_GHZDK as GH_GHK
where ksdm='3201'
这是我写的,但是老师说不对,让我再修改 展开
4个回答
展开全部
--按你的要求要 按照科室 查询一个时间段的挂号人数,你的参数至少要有 开始时间,结束时间,科室 三个参数.
--而且你的过程中根本没有使用你定义的参数@ksrq 和@jsrq,你只是写出了几条语句而已
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
今至电子科技有限公司
2024-08-23 广告
2024-08-23 广告
数据库备份是确保数据安全与业务连续性的关键环节。我们上海今至电子科技有限公司高度重视数据保护,定期执行全面的数据库备份策略。这包括使用先进工具和技术,对关键业务数据进行自动化备份,并存储在安全可靠的外部存储介质或云端。通过定期验证备份的完整...
点击进入详情页
本回答由今至电子科技有限公司提供
展开全部
按照科室统计可以用group by分组,你先试试效果看看是不是你要的。
select sum(a.xmsl) as 挂号人数,ksdm as 科室 from GH_GHMXK as a,GH_GHZDK as b
where a.xh=b.xh and b.ghrq between '20160701' and '20160720' group by ksdm
select sum(a.zje) as 总金额,ksdm AS 科室from SF_BRJSK as a,GH_GHZDK as b
where a.blh = b.blh and b.ghrq between '20160701' and '20160720' GROUP BY ksdm
select sum(a.xmsl) as 挂号人数,ksdm as 科室 from GH_GHMXK as a,GH_GHZDK as b
where a.xh=b.xh and b.ghrq between '20160701' and '20160720' group by ksdm
select sum(a.zje) as 总金额,ksdm AS 科室from SF_BRJSK as a,GH_GHZDK as b
where a.blh = b.blh and b.ghrq between '20160701' and '20160720' GROUP BY ksdm
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是不会写存储过程 还是不会写sql??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-07-22
展开全部
你的表结构贴出来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询