Re: [SQL] complex query

2012-10-28 Thread Oliveiros d'Azevedo Cristina
know about your thoughts on this? Thanks in advance Best, Oliver - Original Message - From: "Scott Marlowe" To: "Mark Fenbers" Cc: Sent: Sunday, October 28, 2012 2:20 AM Subject: Re: [SQL] complex query On Sat, Oct 27, 2012 at 7:56 PM, Mark Fenbers wrote: I&#

Re: [SQL] complex query

2012-10-27 Thread Scott Marlowe
On Sat, Oct 27, 2012 at 7:56 PM, Mark Fenbers wrote: > I'd do somethings like: > > select * from ( > select id, sum(col1), sum(col2) from tablename group by yada >) as a [full, left, right, outer] join ( > select id, sum(col3), sum(col4) from tablename group by bada > ) as b > on (

Re: [SQL] complex query

2012-10-27 Thread Mark Fenbers
I'd do somethings like: select * from ( select id, sum(col1), sum(col2) from tablename group by yada ) as a [full, left, right, outer] join ( select id, sum(col3), sum(col4) from tablename group by bada ) as b on (a.id=b.id); and choose the join type as appropria

Re: [SQL] complex query

2012-10-27 Thread Scott Marlowe
On Sat, Oct 27, 2012 at 6:01 PM, Mark Fenbers wrote: > I have a query: > SELECT id, SUM(col1), SUM(col2) FROM mytable WHERE condition1 = true GROUP > BY id; > > This gives me 3 columns, but what I want is 5 columns where the next two > columns -- SUM(col3), SUM(col4) -- have a slightly different W

Re: [SQL] Complex Query - Data from 3 tables simultaneously

2005-10-28 Thread Amit_Wadhwa
x27; ") 23:59:59' as datetime) Did the above, got the expected results, did not specify 'Outer Join' only specified Join, is that a problem?   From: Muralidharan Ramakrishnan [mailto:[EMAIL PROTECTED] Sent: Friday, October 28, 2005 10:41 PMTo: Wadhwa, Amit; pgsql-sql@postgr

Re: [SQL] Complex Query - Data from 3 tables simultaneously

2005-10-28 Thread Muralidharan Ramakrishnan
SELECT A.SID , A.RECDATE , B.MID , B.MBDATE , C.ISSDATE FROM TableA A LEFT OUTER JOIN TableB B ON   A.SID = B.SIDLEFT OUTER JOIN TableC C ON B.MID = C.MIDORDER BY A.SID[EMAIL PROTECTED] wrote: All,   Using Postgres 8.0 on Windows Server 2003 - 16GB Ram, 3Ghz X 2 Xeons Accessing through JDBC / J

Re: [SQL] Complex Query - Data from 3 tables simultaneously

2005-10-27 Thread Amit_Wadhwa
Thanks a lot, that worked for me! -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: Thursday, October 27, 2005 2:47 PM To: Wadhwa, Amit Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Complex Query - Data from 3 tables simultaneously [EMAIL PROTECTED] wrote

Re: [SQL] Complex Query - Data from 3 tables simultaneously

2005-10-27 Thread Richard Huxton
[EMAIL PROTECTED] wrote: Basically I want a raw dump of data - Should have all the shipments regardless of whether they have any material items entered or not - Should have all Material Items for Every Shipment regardless of whether it was issued or not. I know I need an outer join (Do I Not?