  | | | need one query | need one query 2006-07-01 - By Peter Brawley
Back >orgunit parent value >12 10 x >15 12 y >16 12 z >17 12 p > Now here 15,16, and 17 are the children of 12 and 12 is the >child of 10.Now i need a query which gives the sum of all the children of >12 and nturn 12 itself . i.e I need the sum(values(15+16+17+12)).Is there a >query which gives the sum of all these.It will be very helpful if i am able >to get it in a single query.
SELECT parent, parent + SUM(orgunit) FROM table GROUP BY parent;
PB
-- --
VenuGopal Papasani wrote: > Hi all, > I Have a table with followin structure where i have orgunit and parent > and value > > > orgunit parent value > > 12 10 x > 15 12 y > 16 12 z > 17 12 p > > Now here 15,16, and 17 are the children of 12 and 12 is > the > child of 10.Now i need a query which gives the sum of all the > children of > 12 and nturn 12 itself . i.e I need the sum(values(15+16+17+12)).Is > there a > query which gives the sum of all these.It will be very helpful if i am > able > to get it in a single query. > > Thanks and regards, > venu. > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 6/30/2006 >
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> >orgunit parent value <br> >12 10   ; x <br> >15 12   ; y <br> >16 12   ; z <br> >17 12   ; p <br> > Now here 15,16, and 17 are the children of 12 and 12 is the <br> >child of 10.Now i need a query which gives the sum of all the children of <br> >12 and nturn 12 itself . i.e I need the sum(values(15+16+17+12)).Is there a <br> >query which gives the sum of all these.It will be very helpful if i am able <br> >to get it in a single query. <br> <br> SELECT parent, parent + SUM(orgunit)<br> FROM table <br> GROUP BY parent;<br> <br> PB<br> <br> -- --<br> <br> <br> VenuGopal Papasani wrote: <blockquote cite="midbcb1c3940607010345r1992ed93hfd6ecba09051c9eb@(protected)" type="cite">Hi all, <br> I Have a table with followin structure where i have orgunit and parent <br> and value <br> <br> <br> orgunit parent value <br> <br> 12   ; 10   ; x <br> 15   ; 12   ; y <br> 16   ; 12   ; z <br> 17   ; 12   ; p <br> <br> Now here 15,16, and 17 are the children of 12 and 12 is the <br> child of 10.Now i need a query which gives the sum of all the children of <br> 12 and nturn 12 itself . i.e I need the sum(values(15+16+17+12)).Is there a <br> query which gives the sum of all these.It will be very helpful if i am able <br> to get it in a single query. <br> <br> Thanks and regards, <br> venu. <br> <br> <pre wrap=""> <hr size="4" width="90%"> No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 6/30/2006 </pre> </blockquote> </body> </html>
No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 6/30/2006
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql@(protected)
|
|
 |