|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-02-12 : 19:56:15
|
| Hello All,please help me masters....seems to be big question, but actually it is not, i elaborated clearelyin my Accounts_Info table, it has the below fields(AcctId is primary key) & dataAcctID,DIVID,Name--------- -------- -------PB123, AAA, ABC CorpPB250,AAA, G&ManVR320,BBB, Siebel SoftPB321,CCC ,Menta ParVR322,CCC,KentichyPB267,BBB,Komma KochaVR123,DDD,Global ViePB345,DDD, GSD&KVR560,AAA, integer..........VR870,AAA, CorptelDailyTrans table has below fieldsTrans#,AcctID,TransDate,Amount1,PB123,2008-11-04,-102,PB123,2008-11-05 ,203,VR320,2008-11-05,254,PB123,2008-11-05,155,VR320,2008-11-06,-206,PB267,2008-11-07,157,VR870,2008-11-07,258,PB267,2008-11-08,309,VR560,2008-11-09,3510,VR560,2008-11-09,35.......SELECT a.acctID,b.divid, b.name,sum(a.Amount)FROM DailyTrans a,accounts_Info bWHERE a.acctID=b.acctID and (b.DivCode = 'AAA') AND (a.DataDate between '11/1/2008' and '11/30/2008') group by a.acctID,b.divID,b.nameorder by b.namewhen i run the above sql query it results as belowacctID,divid,name,sum(amount)-------- ------ ------ ----------------PB123,AAA,ABC Corp,25VR870,AAA,Corptel,25VR560,AAA,integer,70if i issue this command SELECT b.divid,sum(a.Amount)FROM DailyTrans a,accounts_Info bWHERE a.acctID=b.acctID and (b.DivCode = 'AAA') AND (a.DataDate between '11/1/2008' and '11/30/2008') group by b.divIDacctID,divid,name,sum(amount)-------- ------ ------ ----------------AAA,120upto here everything goes finenow the question is, when i use second query i want it be if name='integer' then it appears as a separate groupsuch as belowacctID,divid,name,sum(amount)-------- ------ ------ ----------------AAA,50integer,70actually integer is a account name but it needs to be separate group please....Could any one please help mePlease MastersThanks in advancedhani |
|