Here's a modified version that do what you wanted : I used SalesLine just to check if it compiled.
Amount SumAmount; Query queryA; QueryRun queryrunA; QueryBuildDataSource qbdsQ = queryA.dataSourceNo(1); SalesLine salesL; queryA = new Query(tablenum(SalesLine)); qbdsQ.addRange(fieldnum(SalesLine, LineNum)).value('Something'); qbdsQ.orderMode(OrderMode::GroupBy); qbdsQ.addSortField(fieldNum(SalesLine, dataAreaId)); qbdsQ.addSelectionField(fieldNum(SalesLine, QtyOrdered), SelectionField::Sum); queryRunA = new QueryRun(queryA); queryRunA.setRecord(salesL); queryRunA.next(); SumAmount += salesL.QtyOrdered; Steeve... -----Message d'origine----- De : Roberto Pineda [mailto:[EMAIL PROTECTED] Envoyé : 10 mars 2005 12:02 À : Axapta-Knowledge-Village@yahoogroups.com; development-axapta@yahoogroups.com Objet : [Axapta-Knowledge-Village] Question about Queries. Hello to All Is there a way to make a query that gives the same result of doing: select sum(FieldX) from TableX where FieldY == Something; The way i found goes like this, but I am sure that there should be a nicer way. Amount SumAmount; Query queryX; QueryRun queryrunX; TableX tableM; queryX = new Query(tablenum(TableX)); queryX.dataSourceNo(1).addRange(fieldnum(TableX, FieldY)).value('Something'); queryRunA = new QueryRun(queryA); while(queryRunA.next()){ tableM = queryRunA.getNo(1); SumAmount += tableX.FieldX; } It's too slow. Thanks if somebody can help me. Roberto _________________________________________________________ Do You Yahoo!? Información de Estados Unidos y América Latina, en Yahoo! Noticias. Visítanos en http://noticias.espanol.yahoo.com Sharing the knowledge on Axapta. Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> What would our lives be like without music, dance, and theater? Donate or volunteer in the arts today at Network for Good! http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/kGEolB/TM --------------------------------------------------------------------~-> Sharing the knowledge on Axapta. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/Axapta-Knowledge-Village/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/