1

How can I create a VIEW which shows every task for January and March. The project table is linked with the task table via project_no and the employee table is linked to the task table via employee_id. The VIEW also needs to include the task date_time which I have included.

So far I'got got:

CREATE VIEW TASKS_JAN_MAR 
AS SELECT P.NAME, T.TASK_ID, T.TASK_NO, E.FIRST_NAME, E.LAST_NAME, 
TO_CHAR(T.DATE_TIME, 'DD-MON-YY')

FROM PROJECT P, TASK T, EMPLOYEE E

WHERE P.PROJECT_NO = T.PROJECT_NO AND E.EMPLOYEE_ID = T.EMPLOYEE_ID;
Rubikted
  • 43
  • 7
  • Rather than using the older comma-syntax for joined tables, look at more modern ANSI-standard `JOIN` types. Pretty please. https://stackoverflow.com/questions/18891148/oracle-joins-comparison-between-conventional-syntax-vs-ansi-syntax – Shawn Nov 30 '18 at 16:10

1 Answers1

1

Just add another condition to the where clause to constrain the month to Jan (01) or March (03).

CREATE VIEW TASKS_JAN_MAR 
AS SELECT P.NAME, T.TASK_ID, T.TASK_NO, E.FIRST_NAME, E.LAST_NAME, 
TO_CHAR(T.DATE_TIME, 'DD-MON-YY')

FROM PROJECT P, TASK T, EMPLOYEE E

WHERE P.PROJECT_NO = T.PROJECT_NO AND E.EMPLOYEE_ID = T.EMPLOYEE_ID
AND TO_CHAR(T.DATE_TIME,'MM') IN ('01','03')
dcp
  • 54,410
  • 22
  • 144
  • 164