关于一个sql语句

loverdotnet 2009-04-14 09:03:08
select pplt,count(*) as ct from resume group by pplt as t1 join
select pplt,count(*) as ct,pht from resume where datediff(dd,Getdate(),pht)>0 and lz='false' group by pplt,pht as t2
on t1.pplt=t2.pplt


提示as附近有错误,知道的帮帮忙吧
...全文
119 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlb789 2009-04-14
  • 打赏
  • 举报
回复
select * from(
select pplt,count(*) as ct from resume group by pplt) t1
inner join
( select pplt,count(*) as ct,pht from resume where datediff(dd,Getdate(),pht)>0 and lz='false' group by pplt,pht) t2
inner join
(select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),pld)=0 and lz='true' group by pplt,pld
)as t3
inner join
(select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),ptr)=0 and lz='false' group by pplt,pld )as t4
on t1.pplt=t2.pplt and t1.pplt=t3.pplt and t1.pplt=t4.pplt

可以根据不同选择不同的连接方式 left join /right join / inner jion
Fibona 2009-04-14
  • 打赏
  • 举报
回复
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),pld)=0 and lz='true' group by pplt,pld 
union all
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),ptr)=0 and lz='false' group by pplt,pld


不知道楼主第二个问题要得到什么
是下面的结果还是什么?


select * from(
select pplt,count(*) as ct from resume group by pplt) t1 inner join(
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),pld)=0 and lz='true' group by pplt,pld
union all
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),ptr)=0 and lz='false' group by pplt,pld
)t2

on t1.pplt=t2.pplt
ws_hgo 2009-04-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 loverdotnet 的回复:]
后面还有两句,麻烦帮一下忙
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),pld)=0 and lz='true' group by pplt,pld
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),ptr)=0 and lz='false' group by pplt,pld
[/Quote]
这2句话
干什么啊
loverdotnet 2009-04-14
  • 打赏
  • 举报
回复
后面还有两句,麻烦帮一下忙
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),pld)=0 and lz='true' group by pplt,pld
select pplt,count(*) as ct,pld from resume where datediff(mm,Getdate(),ptr)=0 and lz='false' group by pplt,pld
jinjazz 2009-04-14
  • 打赏
  • 举报
回复
select * from(
select pplt,count(*) as ct from resume group by pplt) t1 inner join(
select pplt,count(*) as ct,pht from resume where datediff(dd,Getdate(),pht)>0 and lz='false' group by pplt,pht) t2
on t1.pplt=t2.pplt

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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