Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sha_agrawal
Starting Member
24 Posts |
Posted - 2009-10-19 : 11:36:17
|
| My Regards to all experts I have 2 tables, 1'st table containing fieldsBillNo TotalSaleAmount Another table containing BillNo itemID saleamount.E.g. 2nd table data is1st recordBill No.1ItemID 101SaleAmount 250002nd recordBill No.1ItemID 102SaleAmount 10000I want to use formula for TotalSaleAmount in 1st table to contain bill wise total i.e. 35000. Please help me, how to do it. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-19 : 12:30:02
|
selectBillNo,sum(SaleAmount) as TotalSaleAmountfrom table2group by BillNo No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
sha_agrawal
Starting Member
24 Posts |
Posted - 2009-10-20 : 10:19:45
|
| Sorry to say 'Mr.webfred' but it raise error 'error validating the formula...'. I am using SQL server 2000.Pls.help me |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-10-20 : 15:40:12
|
| can u post the exact query you used? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
sha_agrawal
Starting Member
24 Posts |
Posted - 2009-10-21 : 09:59:01
|
| Thanks Vijay and WebFred for reply, Below are 2 tables I am using :-CREATE TABLE [dbo].[Purch] ( [GSNo] [int] IDENTITY (1, 1) NOT NULL , [TotalContainer] AS "SELECT GSNO,SUM(NoOfContainer) AS TotalContainer FROM PurchDetl GROUP BY GSNo" ,) ON [PRIMARY]CREATE TABLE [dbo].[PurchDetl] ( [GSno] [int] NOT NULL , [ItemId] [int] NOT NULL , [NoOfContainer] [numeric](18, 2) NOT NULL ,) ON [PRIMARY]PurchDetl Records:-GSNO ItemID NoOfContainer134 101 56134 305 72171 476 101 171 902 98Both tables are related with GSNO field.I want to use formula attribute For TotalContiner field existing in Purch table as "SELECT GSNO,SUM(NoOfContainer) AS TotalContainer FROM PurchDetl GROUP BY GSNo" so that sum of containers GS no. wise can be stored in Purch Table. Records of Purch should be as :-GSNO TotalContainer134 128171 199 GS No. will be inserted by front-end software and NoOfContainer field should be filled by the formula.I tried to use formula attribute of TotalContainer as"SELECT GSNO,SUM(NoOfContainer) AS TotalContainer FROM PurchDetl GROUP BY GSNo"but it raises error "Error validating formula....."I think it is now clear. Please help mePlease help me. |
 |
|
|
|
|
|
|
|