帮助进行联接查询和计数 [英] Help with Join Query and count

查看:66
本文介绍了帮助进行联接查询和计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请帮助我进行查询

tbl-A

职位编号,雇主编号,职称,描述,技能,状态


tbl_b

申请编号,职位编号,候选人编号,申请状态

我希望结果如下所示

职位编号,雇主编号,职称,描述,技能,状态,申请人

申请者列是tbl_b组中Jobid的总数

在此先感谢

亲切的问候



Kindly help me with a query

tbl-A

jobid, employerid, jobtitle, description, skills, status


tbl_b

Applicationid, jobid, candidateid,Appliedon status

I want the result to be as below

Jobid, employerid, jobtitle, description, skills, status, Applicants

Applicants column would be total count from tbl_b group by jobid

Thanks in advance

kind regards

推荐答案

该SQL语句如何...

从tbl-A a JOIN tbl_b b ON a.jobid = b.jobid中选择a.jobid,雇主ID,职位,描述,技能,状态,COUNT(b.jobid)

我在另一张桌子上尝试过,看来还可以.


将第一个更改为a.jobid
What about this SQL statement...

SELECT a.jobid, employerid, jobtitle, description, skills, status, COUNT(b.jobid) FROM tbl-A a JOIN tbl_b b ON a.jobid = b.jobid GROUP BY a.jobid

I tried it on a different table and it seemed to work ok.


Changed the first one to a.jobid


select b.jobid,count(b.jobid) as ApplicantsCount,a.* from

tbl_job a inner join tbl_applicants b

on a.jobid=b.jobid

where a.Employerid=@Employerid

group by a.jobid,b.jobid,a.EmployerId,a.CreatedUserId,a.jobtitle,a.categoryid,a.description,a.skills,a.contactperson,a.contactnumber,a.createddate,a.expiredon,a.status


这篇关于帮助进行联接查询和计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆