I have a table Request and Table Search. The Request table has an ID column, which is a foreign key in Search as RequestID. There can be multiple rows in Search with the same RequestID. There’s another column in Search, Status, which can be either Complete or Incomplete. What I want is a query that returns for each RequestID:
RequestID – Count of Search rows with 'Complete' – Count of Search rows with 'Incomplete'
Is this something that can be done easily with SQL?
Try :
If you want to list every RequestId even if there was no search done on this request, you can do :
See SQLFiddle