Is this a bug?
От | Imtiaz. S. M |
---|---|
Тема | Is this a bug? |
Дата | |
Msg-id | 3827B473.62D8C53B@yahoo.com обсуждение исходный текст |
Список | 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
В списке pgsql-sql по дате отправления: