I need one help towards execution of a query as foll.
I am retreiving the data basing on a query using group by clause (groupcode). I also want to retrieve the data by groupcode followed by sortcode. each group there is a sortcode 1 to 4 and so I am able to retrieve the data basing on group but not able to get the data in groupcode and increment by sortcode.
select a.activityid,ss.subscalecode, SN.name, sum(a.AnswerValue) as ANSWERVAL, ss.sortcode,convert(varchar,a.answerdate, 106)
from Answer a, subscale ss, subscalename sn
where a.questioncode in (select questioncode from question where subscalecode = ss.subscalecode) and a.consumerid = 100 and SN.subscalecode = ss.subscalecode
group by a.activityid, ss.subscalecode,sn.name,convert(varchar,a.answerdate, 106) ,ss.sortcode, ss.scalecode
Activity SubScaleCode Name Ans SortCode Date ScaleCode
2 DAY01REL Relationships 2 2 25 Oct 2002 DAY01
2 DAY01RSK Risk Behaviors 2 4 25 Oct 2002 DAY01
2 DAY01SOC Social 2 3 25 Oct 2002 DAY01
2 DAY01WAM Work 3 1 25 Oct 2002 DAY01
I want the SortCode also in an order along with the group of DAY01