Click here to Skip to main content
15,895,256 members
Home / Discussions / Database
   

Database

 
QuestionSQL function?? Pin
leppie1-Nov-02 6:33
leppie1-Nov-02 6:33 
Hi all

I'm not sure what todo....I think I need a function...

This is my problem: I have a table called [References] with a [Rating] (tinyint) field. This field can be NULL or be 1,2,3,4,5 (stars Smile | :) ). Now what I wanna do is get an average of all non-NULL data where the [PersonID] (bigint) field equals a value from a SELECT query. OK I think I need to visualize Smile | :)

Table [References]:
[ID] bigint, (PK)
[PersonID] bigint,
[Rating] tinyint

Table [Users]:
[ID] bigint, (PK)
[Name] varchar(50),
[Role] int

Now I want the data to displayed as follows:

Output Table:
[Users.Name],
[References.AvgRating] ??????

where say [Role] = x

AS you can see I'm clueless Laugh | :laugh: but please help me Wink | ;)

Cheers


"There are no stupid question's, just stupid people."
AnswerRe: SQL function?? Pin
ian mariano1-Nov-02 7:16
ian mariano1-Nov-02 7:16 
GeneralRe: SQL function?? Pin
leppie1-Nov-02 8:40
leppie1-Nov-02 8:40 
GeneralRe: SQL function?? Pin
ian mariano2-Nov-02 7:02
ian mariano2-Nov-02 7:02 
AnswerRe: SQL function?? Pin
Richard Deeming4-Nov-02 2:10
mveRichard Deeming4-Nov-02 2:10 
GeneralRe: SQL function?? Pin
leppie4-Nov-02 7:06
leppie4-Nov-02 7:06 
GeneralBest SQL Server 2000 Book Pin
perlmunger31-Oct-02 9:50
perlmunger31-Oct-02 9:50 
GeneralRe: Best SQL Server 2000 Book Pin
Morten Abrahamsen31-Oct-02 10:34
Morten Abrahamsen31-Oct-02 10:34 
GeneralRe: Best SQL Server 2000 Book Pin
perlmunger31-Oct-02 10:40
perlmunger31-Oct-02 10:40 
GeneralRe: Best SQL Server 2000 Book Pin
Morten Abrahamsen31-Oct-02 10:47
Morten Abrahamsen31-Oct-02 10:47 
GeneralRe: Best SQL Server 2000 Book Pin
perlmunger31-Oct-02 11:03
perlmunger31-Oct-02 11:03 
GeneralRe: Best SQL Server 2000 Book Pin
mikasa1-Nov-02 7:37
mikasa1-Nov-02 7:37 
Questionwhich one is faster??? Pin
LukeV31-Oct-02 6:12
LukeV31-Oct-02 6:12 
AnswerRe: which one is faster??? Pin
leppie31-Oct-02 6:39
leppie31-Oct-02 6:39 
GeneralRe: which one is faster??? Pin
LukeV31-Oct-02 7:14
LukeV31-Oct-02 7:14 
AnswerRe: which one is faster??? Pin
Morten Abrahamsen31-Oct-02 10:38
Morten Abrahamsen31-Oct-02 10:38 
GeneralRe: which one is faster??? Pin
LukeV31-Oct-02 10:52
LukeV31-Oct-02 10:52 
GeneralRe: which one is faster??? Pin
Paul Riley31-Oct-02 11:58
Paul Riley31-Oct-02 11:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.