1) My Table:
Query: select mcdesp,mcidno,mcopsts,hascode from machine
Table:
mcdesp
| mcidno | mcopsts | hascode |
A | A0001 | URWT | #### |
A | A0001 | GOOD | #### |
A | A0001 | GOOD | #### |
B | A0002 | URWP | #### |
B | A0002 | URWP | #### |
C | A0003 | GOOD | #### |
C | A0004 | URWT | #### |
Here i'm generating my hashcode using this script
hascode = HASHBYTES('MD5', CAST(mcidno AS VARBINARY(MAX))+ CAST(mcdesp AS VARBINARY(MAX))+CAST(mcopsts AS VARBINARY(MAX)))
Note: Same Color represents Hascodes are same.
2) My Query and its output:
select mcdesp,count(distinct hascode)as TotalMachine from machine group by mcdesp Let This Tableas "Tbl_Main"
What is the Query for finding Good Machines from my "Tbl_Main"??that is mcopsts='good'. based on Hascode.
I need a Result Like