c# - SQL: Count rows which are not present in table -


i got 2 tables called: employeetable & taskassignmenttable. : tables formation
taskassignmenttable shows tasks assigned employees. in order assign new tasks employees want have count of tasks assigned different people , assign task people have least tasks assigned.
problem: using normal count() on taskassignmenttable results in table: enter image description here
but want sort of join between tables shows count of rows present in first table , absent in 2nd table count equal 0 one:

enter image description here

so sql query join tables , such thing? (optional: since i'm using c# linq-2-sql grateful if can write linq syntax this).

you need left outer join based upon statement want rows present in first table not second:

select employeeid, name, count(taskid) cnt employeetable e left join taskassignmenttable t      on e.employeeid = t.fkemployeeid group employeeid, name 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -