|
-
I don't think this is too easy
SQL> create table my_table
2 (student_id number
3 , course varchar2(30)
4 );
Table created.
SQL>
SQL> insert into my_table values(12,'c');
1 row created.
SQL> insert into my_table values(15,'java');
1 row created.
SQL> insert into my_table values(15,'vb');
1 row created.
SQL> insert into my_table values(13,'c');
1 row created.
SQL> insert into my_table values(13,'java');
1 row created.
SQL> insert into my_table values(14,'cobol');
1 row created.
SQL> insert into my_table values(14,'java');
1 row created.
SQL> insert into my_table values(15,'c');
1 row created.
SQL>
SQL> select * from my_table;
STUDENT_ID COURSE
---------- ------------------------------
12 c
15 java
15 vb
13 c
13 java
14 cobol
14 java
15 c
8 rows selected.
SQL>
SQL> select student_id
2 from my_table
3 where course = 'c'
4 and course = 'java';
no rows selected
SQL>
SQL> select student_id
2 from my_table
3 where course = 'c'
4 or course = 'java';
STUDENT_ID
----------
12
15
13
13
14
15
6 rows selected.
SQL>
SQL> select student_id
2 from my_table
3 having count(decode(course,'c','1','java','1','')) = 2
4 and count(course) = 2
5 group by student_id;
STUDENT_ID
----------
13
SQL>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|