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,
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 #ratin
On Sun, 01 Feb 2009 00:10:52 -0800
Mike Christensen 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)
> );
>
>
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 F