15.09.2008, 10:45 | #1 |
Участник
|
Суммирование строк в таблице
Доброе день.Вот программа.Подскажите как прописать условие суммирования,
т.к есть одинаковые номенклатуры, забитые в один и тотже день, а суммы разные как суммировать. X++: { ProdJournalTable ProdJournalTable; ProdJournalRoute ProdJournalRoute; ProdJournalRoute ProdJournalRoute_1; ProdJournalRoute ProdJOurnalRoute_2; TmpProdJournalRouteOutTime tmpTable; ProdTable ProdTable; int nDay; SysOperationProgress sop; int cntItems; date fromDate = 01\09\2008; date toDate = 31\09\2008; ; delete_from tmpTable; select count (Recid)from Prodjournaltable exists join ProdJournalRoute where ProdJournalRoute.JournalId==ProdJournalTable.JournalId&& ProdJournalTable.Createddate >= fromDate && ProdJournalTable.createdDate <= toDate && (ProdJournalRoute.WrkCtrId == '113' || ProdJournalRoute.WrkCtrId == '135'); cntItems = ProdJournalTable.RecId; sop = SysOperationProgress::newGeneral('','',cntItems); // преоброзование шкалы while select createddate,journalid,posted,posteddate From ProdJournalTable exists join ProdJournalRoute where ProdJournalRoute.JournalId==ProdJournalTable.JournalId&& ProdJournalTable.Createddate >= fromDate && ProdJournalTable.createdDate <= toDate && (ProdJournalRoute.WrkCtrId == '113' || ProdJournalRoute.WrkCtrId == '135') { select ProdJournalRoute_1 order by oprnum desc where ProdJournalRoute_1.JournalId == ProdJournalTable.JournalId; select ProdTable where ProdTable.ProdId == ProdJournalRoute_1.ProdId; select ProdJournalRoute_2 where ProdJournalRoute_2.OprId like '045*' && ProdJournalRoute_2.JournalId == ProdJournalTable.JournalId; sop.incCount(); /* info ( strfmt("%1,%2,%3", ProdJournalTable.createdDate, ProdJournalTable.JournalId, toDay() - ProdJournalTable.createdDate) );*/ tmpTable.clear(); tmpTable.ITEMID =ProdTable.ItemId; tmpTable.WRKCTRID=ProdjournalRoute_1.WrkCtrId; tmpTable.Qty=ProdJournalRoute_1.QtyGood+ProdJournalRoute_1.QtyError; if(ProdJournalTable.Posted==noyes::No) { tmpTable.Days= (toDay() - ProdJournalTable.createdDate)+1; //toDay() - ProdjournalRoute_1.transDate; } else { tmpTable.Days=(ProdJournalTable.PostedDate - ProdJournalTable.createdDate)+1 ; } tmpTable.Normal=noYes::No; if ( tmpTable.WRKCTRID == '135') { nDay = 1; } if ( tmpTable.WRKCTRID == '113') { if (ProdJournalRoute_2 != NULL) { nDay=5; } else { nDay = 3; } } if (tmpTable.Days > nDay) tmpTable.Normal=NoYes::No; else tmpTable.Normal=NoYes::Yes ; tmpTable.insert(); } |
|