Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need some advice
Message
From
23/03/2000 08:42:43
 
 
To
22/03/2000 09:33:33
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00348846
Message ID:
00349327
Views:
20
Rajesh,

Does this stored procedure run? The query that you use to calculate the openning balance is not legal. You can't have columns in the column list of a query that contains a GROUP BY unless the columns appear in a aggregate function or they also appear in the GROUP BY clause.

Try something like this:
insert into #db_ledger (glcd,gldt,glfl,glblno,glblsrno,glamnt,glnarr)
values (
 @LEDcode, 
 gldt=@fromdate, 
 glfl = "OPENING",
 glblno='',
 glblsrno='',
 GLAMNT = (SELECT SUM(GLAMNT) from genled where glcd = @LEDcode and gldt<fromdate GROUP by glCD), 
"Opening Balance")
Setting the balance is a matter of summing all the records that are less than the date on the current record. You can use a collorated query
UPDATE #db_ledger SET balance = 
 (SELECT SUM(glamnt) FROM #db_ledger d WHERE d.gldt < #db_ledger.gldt)
-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform