mercredi 28 janvier 2015

im getting wrong count in sql


Vote count:

0




Sequel count returning wrong value.i have written a query to count the no of same cells , but its giving incorrect data. kindly tell me where i did wrong. kindly tell why it is not getting 2 in ananth record in below grid


sql query -



SELECT username,
Sum(improved) IMPROVED,
Sum(decreased) DECREASED,
Sum(nochange) NoChange,
Sum(timelinecompleted) TimeLineCOMPLETED,
Sum(tlnotcompleted) TLNotCompleted
FROM (SELECT ( k.keyword ),
p.projectname,
pa.username,
CASE
WHEN b.currentposition > a.currentposition THEN 1
ELSE 0
END IMPROVED,
CASE
WHEN a.currentposition > b.currentposition THEN 1
ELSE 0
END DECREASED,
CASE
WHEN a.currentposition = b.currentposition THEN 1
ELSE 0
END NoChange,
CASE
WHEN pa.keywordstatus = 'Stopped' THEN 1
ELSE 0
END TimeLineCOMPLETED,
CASE
WHEN pa.keywordstatus = 'InProgress' THEN 1
ELSE 0
END TLNotCompleted,
b.currentposition AS oldposition,
a.currentposition AS newposition,
pa.keywordstatus AS TimeLineStatus,
k.targetdate,
k.positionexp
FROM seo.tbl_keywordposition a
JOIN seo.tbl_keywordposition b
ON a.keywordid = b.keywordid
AND a.psnupdatedate = '1/22/2015'
AND b.psnupdatedate = '1/23/2015'
LEFT JOIN tbl_keywords k
ON k.keywordid = a.keywordid
AND a.keywordid = b.keywordid
LEFT JOIN tbl_project p
ON p.projectid = k.projid
LEFT JOIN tbl_projassignment pa
ON pa.projid = p.projectid
AND pa.keywordid = k.keywordid
WHERE p.projectname = 'Homeocare')INNERQUERY
GROUP BY username


enter image description here



asked 45 secs ago







im getting wrong count in sql

Aucun commentaire:

Enregistrer un commentaire