Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Plz Solve this sql Query..
Venkatesan
Jun 21 2013 8:46 AM
1.1k
Reply
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
mcdesp
TotalMahine
A
2
B
1
C
2
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
mcdesp
GOOD
A
1
B
0
C
1
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
sql query
what is table value parameters in SQL