Advanced SQL statements writing

From: Phper <hi.steven.tu_at_gmail.com>
Date: Thu, 16 Apr 2009 07:11:21 -0700 (PDT)
Message-ID: <9b2b9f2e-30b7-4b9d-adcf-88a115d8549a_at_j9g2000prh.googlegroups.com>



I wrote this SQL statement:

SELECT *
FROM ((SELECT piecework_id,1+count(*)
FROM view
GROUP BY piecework_id) AS view1
LEFT OUTER JOIN
(SELECT piecework_id, sum(status)
FROM submission
GROUP BY piecework_id) AS submission1
on view1.piecework_id=submission1.piecework_id);

It can be executed successfully.
This is the result.

piecework_id 	1+count(*) 	piecework_id 	sum(status)
8 	                      2   	           8	                  NULL
989 	                      2 	           NULL 	           NULL

But I want the result to be
piecework_id 	1+count(*) 	sum(status)
8 	                      2   	         NULL
989 	                      2 	         NULL

How can I achieve this? Received on Thu Apr 16 2009 - 09:11:21 CDT

Original text of this message