Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Query Question. Pls help
Try this:
insert into sub_student_result (studno, subj2, subj3)
select b.student_no, decode(a.subject, 'subj2',a.result),
decode(a.subject,'subj3',a.result)
from result a, sub_student b
where b.student_no = a.student_no;
I hope I understood your question.
-Eric
Alan Kong wrote:
> Hi,
>
> I need help on the following problem.
>
> I have a student result table:
>
> Table Result:
> Student No. year Subject Result
> *********** **** ******* ******
> s1 1994 subj1 A
> s1 1995 subj2 B
> s2 1994 subj1 A
> s2 1995 subj3 C
> s3 1995 subj2 B
> s3 1995 subj3 A
> ................
>
> A student table which consists a sub-set of students from table Result.
>
> Table: sub-student
> Student No.
> **********
> s1
> s3
>
> I would like create a list which only extracts certain subjects from
> result table and the students are from table sub-student.
>
> Student No. subj2 subj3
> *********** ***** *****
> s1 B
> s3 B A
>
> I have created a new table sub-student-result with the following fields:
> studno, subj2, subj3
>
> But I don't know how to extract the results into this new table.
>
> Thanks in advance for your help.
>
> --
> Regards
>
> Alan
>
> *****************************************************************************
> Alan, Kwok-Kee KONG | Email: kkkong_at_ee.cuhk.hk
> Department of Electronic Engineering | alan_at_ee.cuhk.hk
> The Chinese University of Hong Kong | Tel: +852 2609-8286 (voice)
> Shatin, N.T. | +852 2603-5558 (fax)
> Hong Kong
> *****************************************************************************
Received on Thu Jun 11 1998 - 14:16:55 CDT