Re: [SQL] complex query

2012-10-28 Thread Oliveiros d'Azevedo Cristina
thoughts on this? Thanks in advance Best, Oliver - Original Message - From: Scott Marlowe scott.marl...@gmail.com To: Mark Fenbers mark.fenb...@noaa.gov Cc: pgsql-sql@postgresql.org Sent: Sunday, October 28, 2012 2:20 AM Subject: Re: [SQL] complex query On Sat, Oct 27, 2012 at 7:56 PM

[SQL] complex query

2012-10-27 Thread Mark Fenbers
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 WHERE clause, i.e., WHERE

Re: [SQL] complex query

2012-10-27 Thread Scott Marlowe
On Sat, Oct 27, 2012 at 6:01 PM, Mark Fenbers mark.fenb...@noaa.gov 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

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

Re: [SQL] complex query

2012-10-27 Thread Scott Marlowe
On Sat, Oct 27, 2012 at 7:56 PM, Mark Fenbers mark.fenb...@noaa.gov 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

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

2005-10-29 Thread Amit_Wadhwa
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@postgresql.orgSubject: Re: [SQL] Complex

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 / JSP

[SQL] Complex Query - Data from 3 tables simultaneously

2005-10-27 Thread Amit_Wadhwa
All, Using Postgres 8.0 on Windows Server 2003 - 16GB Ram, 3Ghz X 2 Xeons Accessing through JDBC / JSP I have 3 shipment tables. Table A - Records arrived Shipments. Table B - Records Materials (maybe more than one per shipment) in the shipment. Table C - Records Issuances of material

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

[SQL] complex query

2003-03-03 Thread Matt Gerginski
I have two tables, users and options. The common element between the tables is username. I want to select the email from user but only if the mailing_list option is set to true in the options table. Here are the tables: select username, email from users; username| email

[SQL] Complex query

2000-08-27 Thread J. Fernando Moyano
Hey everybody !!! I am new on this list !!! I have a little problem . I try this on my system: "select n_lote from pedidos except select rp.n_lote from relpedidos rp, relfacturas rf where rp.n_lote=rf.n_lote group by rp.n_lote having sum(rp.cantidad)=sum(rf.cantidad)" I get this