On Sun, 01 Feb 2009 00:10:52 -0800
Mike Christensen ima...@comcast.net wrote:
Figured out one way to do it, perhaps I can get some feedback on
if this is the best way.. Thanks!
CREATE TEMP TABLE temp_ratings
(
RecipeId uuid,
Rating smallint,
CONSTRAINT id_pk PRIMARY KEY (RecipeId)
Hi guys, I'm in the process of migrating my database from MS SQL 2005 to
PostgreSQL and there's one final stored proc that's giving me some
problems.. Perhaps someone can give me some help? Here's the sproc:
SELECT
RecipeId, Avg(Rating) as Rating
INTO #ratings
FROM RecipeRatings GROUP
Hi,
Mike Christensen wrote:
Hi guys, I'm in the process of migrating my database from MS SQL 2005 to
PostgreSQL and there's one final stored proc that's giving me some
problems.. Perhaps someone can give me some help? Here's the sproc:
SELECT
RecipeId, Avg(Rating) as Rating
INTO
Figured out one way to do it, perhaps I can get some feedback on if this
is the best way.. Thanks!
CREATE TEMP TABLE temp_ratings
(
RecipeId uuid,
Rating smallint,
CONSTRAINT id_pk PRIMARY KEY (RecipeId)
);
INSERT INTO temp_ratings(RecipeId, Rating)
SELECT RecipeId, Avg(Rating) as Rating
Thanks! You might be onto something, I see two potential problems though:
1) If the nested select returns no rows (no one has rated the recipe
before), it would try to set the value to null. The Rating column is
non-nullable which is the way I want it.
2) I'm not exactly 100% sure on this,