0

私はリストTaskListの中GridView1と右にリストしています 私は労働者リストのhaving different skills under oneserviceCategoryIDを表示しています。GridView1行とすべてのをクリックすると、ワーカー リストの表示がフィルタリングされWorkers with multiple skills under one serviceCategoryID are Listed in GridView2ます。

タスクをワーカーに割り当てる前にPendingTasks、そのワーカーGridView2の数を表示したいList of Workers with multiple skills under one selected serviceCategoryID from GridView1.

現在の SQL クエリは次のとおりです。

SELECT WorkerMst.workerID, WorkerMst.FName, WorkerMst.LName,WorkerMst.FName +' '+ WorkerMst.LName as Name,WorkerSkills.WorkerSkillsID,
     WorkerSkills.WorkerID AS WorkerSkills_WorkerID, WorkerSkills.SkillTypeID AS WorkerSkills_SkillTypeID, WorkerSkills.Score, skillTypeMst.skillTypeID, skillTypeMst.skillType, 
     serviceCategoryMaster.serviceCategoryMasterID, serviceCategoryMaster.CategoryName, WorkerMst.IsActive AS WorkerMst_IsActive,WorkerMst.IsIndividual,WorkerMst.readyfornewtask,
     (select count(WorkerID)from WorkerTask where isAproved=0 and workerid in (select distinct(workerid) from workertask where isaproved=0 group by workerid)) as PendingTsks

 FROM WorkerMst 
 INNER JOIN WorkerSkills ON WorkerMst.workerID = WorkerSkills.WorkerID 
 INNER JOIN skillTypeMst ON WorkerSkills.SkillTypeID = skillTypeMst.skillTypeID 
 INNER JOIN serviceCategoryMaster ON skillTypeMst.serviceCategoryMasterID = serviceCategoryMaster.serviceCategoryMasterID
where skillTypeMst.serviceCategoryMasterID=1 and 
WorkerMst.workerID in (select distinct(workerid) from workertask where isaproved=0)
order by workermst.workerid

ここに画像の説明を入力

WorkerTaskテーブルには次のフィールドがあります:

WorkerID,TaskMstID,IsAccepted ,IsRejected,OnDate,isAproved

なにか提案を?助けて感謝!前もって感謝します!

4

2 に答える 2

1

テーブルのスキーマを提供していませんが、WorkerTaskテーブルには (任意の) ワーカーへのタスク割り当て用に 1 つの行があると想定しています。それがこのテーブルの主キーであると想定しているWorkerTaskIdため、次のクエリで十分です。

SELECT 
     WorkerMst.workerID, WorkerMst.FName, WorkerMst.LName,
     WorkerMst.FName +' '+ WorkerMst.LName as Name,WorkerSkills.WorkerSkillsID,
     WorkerSkills.WorkerID AS WorkerSkills_WorkerID, 
     WorkerSkills.SkillTypeID AS WorkerSkills_SkillTypeID, WorkerSkills.Score,
     skillTypeMst.skillTypeID, skillTypeMst.skillType, 
     serviceCategoryMaster.serviceCategoryMasterID, serviceCategoryMaster.CategoryName, 
      WorkerMst.IsActive AS WorkerMst_IsActive, WorkerMst.IsIndividual, 
      WorkerMst.readyfornewtask,
     (select count(t.workertaskid)from WorkerTask t
         where t.isAproved=0 and t.workerid = WorkerMst.workerid) as PendingTsks
 FROM WorkerMst 
 INNER JOIN WorkerSkills ON WorkerMst.workerID = WorkerSkills.WorkerID 
 INNER JOIN skillTypeMst ON WorkerSkills.SkillTypeID = skillTypeMst.skillTypeID 
 INNER JOIN serviceCategoryMaster 
    ON skillTypeMst.serviceCategoryMasterID =  serviceCategoryMaster.serviceCategoryMasterID
where skillTypeMst.serviceCategoryMasterID=1 
order by workermst.workerid
于 2013-01-11T10:15:20.890 に答える
0

変更されたクエリは次のとおりです。

SELECT 
     WorkerMst.workerID, WorkerMst.FName, WorkerMst.LName,
     WorkerMst.FName +' '+ WorkerMst.LName as Name,WorkerSkills.WorkerSkillsID,
     WorkerSkills.WorkerID AS WorkerSkills_WorkerID, 
     WorkerSkills.SkillTypeID AS WorkerSkills_SkillTypeID, WorkerSkills.Score,
     skillTypeMst.skillTypeID, skillTypeMst.skillType, 
     serviceCategoryMaster.serviceCategoryMasterID, serviceCategoryMaster.CategoryName, 
      WorkerMst.IsActive AS WorkerMst_IsActive, WorkerMst.IsIndividual, 
      WorkerMst.readyfornewtask,(select count(workerid)from WorkerTask 
         where isAproved=0 and workerid = WorkerMst.workerid) as PendingTsks

 FROM WorkerMst 
 INNER JOIN WorkerSkills ON WorkerMst.workerID = WorkerSkills.WorkerID 
 INNER JOIN skillTypeMst ON WorkerSkills.SkillTypeID = skillTypeMst.skillTypeID 
 INNER JOIN serviceCategoryMaster 
    ON skillTypeMst.serviceCategoryMasterID =  serviceCategoryMaster.serviceCategoryMasterID
where skillTypeMst.serviceCategoryMasterID=1 and WorkerSkills.Score>=70
order by workermst.workerid

あなたの提案をありがとう@VinayC!

于 2013-01-11T10:42:29.780 に答える