| Author |
Topic |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2009-04-22 : 05:39:07
|
| Dear All,I tried following queary in that s queary output getting properly. Now i want AbsId related that s queary name. I am getting error following error. I think sytax wrong.Can anybody plz correct the syntax or solve it.Queary:select AbsId from ostt where s.Name from(select I4.DocEntry,I4.TaxRate,ot.NfTaxId,oa.Name,sum(I4.TaxSum) as taxamountfrom inv4 I4left join ostt ot on ot.AbsId = I4.StaTypeleft join osta oa on I4.StaCode = oa.Codewhere I4.DocEntry = '91'group by I4.DocEntry,I4.TaxRate,ot.NfTaxId,oa.Name )sError:Msg 156, Level 15, State 1, Line 2Incorrect syntax near the keyword 'from'.Msg 102, Level 15, State 1, Line 10Incorrect syntax near 's'.Harish Patil |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-22 : 05:43:40
|
[code]SELECT DISTINCT ot.AbsIDFROM inv4 AS i4LEFT JOIN ostt AS ot ON ot.AbsId = i4.StaTypeLEFT JOIN osta AS oa ON oa.Code = i4.StaCodeWHERE i4.DocEntry = '91'GROUP BY i4.DocEntry, i4.TaxRate, ot.NfTaxId, oa.Name[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2009-04-22 : 06:17:02
|
| Dear peso,In my previous queary in s queary i used group by for Name also. I want related that Name want AbsId. And this AbsId is unique.91 1.000000 -50 HCESS 306.06000091 1.000000 -3 OCT_SER 106.56000091 2.000000 -50 ECESS 612.12000091 3.000000 -3 OCTROI 10655.43000091 4.000000 -7 VAT_4 14091.30000091 10.000000 -50 Excise 30605.940000Now i want following output,7 HCESS 306.0600008 OCT_SER 106.5600009 ECESS 612.12000010 OCTROI 10655.43000011 VAT_4 14091.30000012 Excise 30605.940000Means i want AbsId only related that name.Harish Patil |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-04-22 : 06:28:36
|
| You're not being very clear about what you want or the structure of your tables but looks like you just want AbsId, Name, taxamount so maybeselect ostt.AbsId, oa.Name, sum(I4.TaxSum) as taxamountfrom inv4 I4left join ostt ot on ot.AbsId = I4.StaTypeleft join osta oa on I4.StaCode = oa.Codewhere I4.DocEntry = '91'group by ostt.AbsId, oa.Name==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2009-04-22 : 06:35:26
|
| Dear freind,U r getting correct my problem. It is work. But in this i want grouping by Name but in that AbsId is different. Plz see the following output of ur queary. 8 ECESS 612.1200007 Excise 30605.9400009 HCESS 306.06000011 OCT_SER 105.33000014 OCT_SER 1.23000010 OCTROI 10532.60000013 OCTROI 122.83000012 VAT_4 13928.86000015 VAT_4 162.440000And ur queary is as follows. Plz tell me how to do grouping by name.select ot.AbsId, oa.Name, sum(I4.TaxSum) as taxamountfrom inv4 I4left join ostt ot on ot.AbsId = I4.StaTypeleft join osta oa on I4.StaCode = oa.Codewhere I4.DocEntry = '91'group by ot.AbsId, oa.Name |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-22 : 06:48:11
|
select MAX(ot.AbsId), oa.Name, sum(I4.TaxSum) as taxamountfrom inv4 I4left join ostt ot on ot.AbsId = I4.StaTypeleft join osta oa on I4.StaCode = oa.Codewhere I4.DocEntry = '91'group by oa.Name E 12°55'05.63"N 56°04'39.26" |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2009-04-22 : 07:57:08
|
| Dear Peso,Tnks for the reply. Can u plz send me ur mail id so i can send u my deatils queary to u. Coz i am not able to send the attachement through sqlteam forum.Harish Patil |
 |
|
|
|