I have a simple select
query
select count(status_flag) STATUS_COUNT
from inward_doc_tracking_hdr
where to_user = 1279 and status_flag = 4
which displays results as
I have joined with user_mst
table like below:
SELECT COUNT (a.status_flag) counts, a.mkey, a.to_user, b.email,
b.first_name + ' ' + b.last_name name
FROM inward_doc_tracking_hdr a
LEFT JOIN user_mst b ON a.to_user = b.mkey
WHERE a.to_user = '1279' AND a.status_flag = '4'
group by a.mkey, a.to_user, b.email, b.first_name,b.last_name
which displays result as
So my issue is
why the second query is showing two rows for the same
to_user
whose count is 2.
I am using sql-server-2005