pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Imtiaz. S. M <imtiaz_sm@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Is this a bug?
Date: Tue, 09 Nov 1999 11:13:16 +0530
Message-ID: <3827B473.62D8C53B@yahoo.com> (raw)

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





view thread (7+ messages)  latest in thread

Message-ID: <3827B473.62D8C53B@yahoo.com>
Permalink:  ../3827B473.62D8C53B@yahoo.com/
Also on:    postgresql.org/message-id/3827B473.62D8C53B@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: imtiaz_sm@yahoo.com
  Subject: Re: Is this a bug?
  In-Reply-To: <3827B473.62D8C53B@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox