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 ValechaRank #794 · 2.9K reputationPosted Dec 29, 2014, 8:49 PM EST
Please describe the database structure.
Like
Table Name -
Columns DataType
and add 3-4 sample rows.
Danish HabibRank #2,024 · 715 reputationPosted Dec 29, 2014, 9:07 PM EST
Riddhi ValechaRank #794 · 2.9K reputationPosted Dec 29, 2014, 9:32 PM EST
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.