我有两个表,我想提取以下要求:
表格和示例数据:
**Job_Applied** **Jobs_posted**
Job_id Empl_id User_id | Job_id Empl_id Job_Title
------------------------ --------------------------
1 2 3 | 1 2 Android
1 2 4 | 2 2 Web
1 2 5 | 3 4 Java
2 2 3 |
2 2 3 |
2 2 7 |
3 2 5 |
我尝试过:
Select count(User_id) as Users , Job_Title
from Jobs_posted
inner join Jobs_Applied on Jobs_posted.job_id = Jobs_Applied.job_id.
我得到了申请工作的用户数量。如何获得零用户数的job_title。我也尝试过左加入。请帮助。
答案 0 :(得分:0)
您只需要按Job_Title
Select count(distinct User_id) as Users , p.Job_Title
from Jobs_posted p
left join Jobs_Applied a
on p.job_id = a.job_id and p.Empl_id = a.Empl_id
group by p.Job_Title
答案 1 :(得分:0)
使用左联接
orderby new SomeType() {NewField = [entity].DbField, Id = [entity].Id}.Id desc
orderByExpression.Body {p => p.Id}
resultExpression
.Call System.Linq.Queryable.OrderByDescending(
.Call System.Linq.Queryable.Select(
.Call System.Linq.Queryable.Where(
.Call System.Linq.Queryable.Where(
.Constant<Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[MyTypeView]>(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[MyTypeView]),
'(.Lambda #Lambda1<System.Func`2[MyTypeView,System.Boolean]>)),
'(.Lambda #Lambda2<System.Func`2[MyTypeView,System.Boolean]>)),
'(.Lambda #Lambda3<System.Func`2[MyTypeView, MyTypeResult]>))
,
'(.Lambda #Lambda4<System.Func`2[MyTypeResult,System.Guid]>))