
June 9th, 2003, 03:25 PM
|
 |
Me likey breadsticks...
|
|
Join Date: Jan 2003
Location: Los Angeles
|
|
Ok, I guess there's a few things to address:
1)The error message. The error message is saying that Postgres does not recognize the IF function you are trying to use, meaning that there is no IF function, or the paramaters that you are passing to the IF function are of the wrong type and may need casting to the correct types. Off the top of my head I don't know if Postgres has an exact corollary to that MySQL IF function, perhaps one of the mods or more experienced PG developers can answer that.
2)How can you get the same type of resulting output from Postgres ?
You can probably do (basing my db structure off of the link you gave in here
Try something like this (note untested query as I don't have a DB like this lying around):
SELECT location, SUM(CASE gender='M' THEN 1 ELSE 0 END) AS M, SUM(CASE gender='F' THEN 1 ELSE 0 END) AS F FROM locations, employees WHERE locations.loc_code = employees.loc_code GROUP BY location;
HTH helps,
-b
__________________
PostgreSQL, it's what's for dinner...
|