Re: Help with SELECT statement

From: Paul Murphy <pmurphy_at_scsinet.com>
Date: Tue, 22 Apr 2003 05:01:25 GMT
Message-ID: <F04pa.23557$5f4.3049_at_twister.nyroc.rr.com>


[Quoted] "Tuan Nguyen" <tuan_at_cao-lanh.com> wrote in message news:4hf9avgedtm1fhs97jha1amistpe8j4els_at_4ax.com...
> Hi all:
>
> I have the following table called STUDENTSCORES
> that looks something like this:
>
> ================================================
> | LastName | FirstName | Score | MakeupScore|



> | Summer | Kathy | 90 | |


> | Abad | Joe | | 95 |


> | Wolf | Eric | 74 | |


> | Sloan | Jim | | 65 |
> ================================================
>
> how would i be able to select from it so that it
> would display all the students' names and the
> scores they have from the approriate column? Like
>
> Kathy Summer 90
> Joe Abad 95
> Eric Wolf 74
> Jim Sloan 65
>
> Thanks so much for any help!
>
> Regards,
> Tuan

I assume none of the students would ask for homework answers and also none of them will have both a score and makeup score.There is more than one way to do it, but I'd probably try:

SELECT firstname, lastname, score || makeupscore as grade FROM studentscores;

or

SELECT firstname, lastname, score FROM studentscores WHERE score IS NOT NULL UNION
SELECT firstname, lastname, makeupscore FROM studentscores WHERE makeupscore IS NOT NULL; This can probably end up like a Rube Goldberg contest to see who can write the most complex SQL query to do the job...

Paul Murphy Received on Tue Apr 22 2003 - 07:01:25 CEST

Original text of this message