Received: from venkat.vxl.co.in ([202.54.39.170]) by hub.org (8.9.3/8.9.3) with ESMTP id AAA56648 for ; Tue, 9 Nov 1999 00:40:51 -0500 (EST) (envelope-from imtiaz_sm@yahoo.com) Received: from yahoo.com (root@localhost [127.0.0.1]) by venkat.vxl.co.in (8.8.7/8.8.7) with ESMTP id LAA03753 for ; Tue, 9 Nov 1999 11:13:36 +0530 Sender: root@venkat.vxl.co.in Message-ID: <3827B473.62D8C53B@yahoo.com> Date: Tue, 09 Nov 1999 11:13:16 +0530 From: "Imtiaz. S. M" Organization: VXL Instruments Ltd. X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i686) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Is this a bug? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have the following table named 'emp_test' whose structure is as follows Table = emp_test +----------------------------------+----------------------------------+-------+ | Field | Type | Length| +----------------------------------+----------------------------------+-------+ | employee_num | char() | 10 | | salary | int4 | 4 | +----------------------------------+----------------------------------+-------+ The table contains the following records; employee_num|salary ------------+------ 100 | 1000 200 | 2000 300 | 3000 400 | 4000 500 | 5000 100 | 1111 200 | 2222 300 | 3333 400 | 4444 500 | 5555 (10 rows) Now I create a view with the following SQL statement. create view emp_view as select employee_num,sum(salary) from emp_test group by employee_num; Then I give the following query on the view. select * from emp_view for which the output is as follows. employee_num| sum ------------+----- 100 | 2111 200 | 4222 300 | 6333 400 | 8444 500 |10555 (5 rows) This is perfectly right Now I give the following query select count(*) from emp_view and the output is as follows count ----- 2 2 2 2 2 (5 rows) This is what does not make sense to me because I am expecting the no. of rows to be returned I need to issue these kind of queries because I would like to find out the number or percentage of people earning a salary in a particular range and etc. I have solved the problem by creating temporary tables instead of views where these kind of queries work perfectly fine. But this does not seem to be a good idea since I have to port my software to different RDBMSs' later. Can somebody help me? Thanks in advance regards Imtiaz