dear below is the query
SELECT SUM(CAST(CAST(QT.QuestionTarget AS FLOAT)AS INT)) AS Indicator01Target ,SUM(CAST(CAST(A.Question01Total AS FLOAT)AS INT)) AS Achievement from QuestionTarget QT
inner JOIN Answers AS A ON A.Question01=QT.Question_ID
Where QT.Question_ID=1
The problem is that My I have Two Tables
1-QuestionTarget
2-Answer
My Indicator01Target is also in Answer table instead of getting its value form QuestionTarget table it is getting its value from Answer Table
Loading

Riddhi ValechaPosted Dec 30, 2014, 2:32 AM
I am assuming that there is a Question Master Table also in the database.
Query-
select (select Question from QuestionMaster where QuestionMaster.ID =QuestionTarget.QuestionID) as Question, QuestionTarget.TargetValue,
(select AnswerTable.AchievedValue from AnswerTable where AnswerTable.QuestionID = QuestionTarget.QuestionID) as AchievedAnswer, (case if TargetVale = AchievedAnswer then /*addition*/ if TargetValue <> AchievedAnswer then /**/) end case from QuestionTarget.
--------
PLease change the table names and column names.
THis is s rough query.
Danish HabibPosted Dec 30, 2014, 2:07 AM
Riddhi ValechaPosted Dec 30, 2014, 1:49 AM
Please describe the database structure.
Like
Table Name -
Columns DataType
and add 3-4 sample rows.