Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Challenging Query Problem!
Base table:
MyTable:
Name Assignment Mark
==== ======== ====
name1 assignment1 10
name2 assignment1 9
name3 assignment1 9
name1 assignment2 12
name2 assignment2 15
name3 assignment2 11
select name, assignment1, assignment2 from
( select name, mark assignment1 from MyTable
where assignment = 'ASSIGNMENT1') a
( select name, mark assignment2 from MyTable
where assignment = 'ASSIGNMENT2') b
( select distinct name from MyTable) c
where a.name = c.name
and b.name = c.name
Will output
NAME Assignment1 Assignment2
name1 10 12 name2 9 15 name3 9 11
Have a look at inline views in the Oracle documentation. Inline views are the subqueries I've done in the from clause.
Hope this helps,
-- Gerrit-Jan Linker web: http://www.oraxcel.com email: gjlinker_at_oraxcel.com Oraxcel: Linking Oracle to Excel OraCodes: Explaining ORA- error codes OraSQL: Explaining Oracle SQL syntax OraDebug: PL/SQL debugger OraWeb: Oracle access from IE Eddie <edawad_at_hotmail.com> wrote in message news:8ctmg5$296$1_at_nnrp1.deja.com...Received on Tue Apr 11 2000 - 00:00:00 CDT
> Hi, I have a query which has the following output:
>
> name1 assignment1 10
> name2 assignment1 9
> name3 assignment1 9
> name1 assignment2 12
> name2 assignment2 15
> name3 assignment2 11
>
> What I want is the following:
>
> NAME Assignment1 Assignment2
> name1 10 12
> name2 9 15
> name3 9 11
> I have absolutely no idea how do this. Neither the number of students
> (name1, name2....) is fixed nor the number of assignments. Any help is
> greatly appreciated. Thanks.
>
> --
> Eddie
> Web Application Developer
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.