From: | "Imtiaz(dot) S(dot) M" <imtiaz_sm(at)yahoo(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Is this a bug? |
Date: | 1999-11-09 05:43:16 |
Message-ID: | 3827B473.62D8C53B@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Stoyan Genov | 1999-11-09 11:15:34 | Re: [SQL] Move forward all (Was Re: How to get last 10 rows in a table on a large database?) |
Previous Message | Frederic boucher | 1999-11-09 05:28:12 | Re: [SQL] parser :parse error |