I have below 2 Tables I need to get output witout temp tables
WorkItem
ItemID ItemName Status
1 xyz 3
2 abc 3
3 MNO 2
WorkItemTrack
TrackID ItemID Status
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 3 1
7 3 2
This is my Query
select ItemName, WorkItem.Status from WorkItem Inner join WorkItemTrack ON WorkItem.ItemID=WorkItemTrack.ItemID
where WorkItemTrack.Status=2
& this my output
ItemName Status
XYZ 3
ABC 3
MNO 2
But I need output for only MNO with status 2
ie
ItemName Status
MNO 2
how to do without using temp tables
You could either do
or
(if you need to get more complex later and want to do other things with the initial results)