SELECT Template_Details, Template_Type_Code, Template_ID FROM Templates WHERE "Version_Number" <= 5 OR Date_Effective_From = "1986-11-14 12:20:18" OR Template_Type_Code = "AD" AND Date_Effective_To = "1998-05-12 12:51:29" UNION SELECT Template_Details, Template_Type_Code, Template_ID FROM Templates WHERE "Version_Number" = 7 AND Date_Effective_To = "2001-04-18 09:29:52" <table_name> : Templates col : Template_ID | Version_Number | Template_Type_Code | Date_Effective_From | Date_Effective_To | Template_Details row 1 : 0 | 5 | PP | 2005-11-12 07:09:48 | 2008-01-05 14:19:28 |  row 2 : 1 | 9 | PP | 2010-09-24 01:15:11 | 1999-07-08 03:31:04 |  row 3 : 4 | 4 | BK | 2002-03-02 14:39:49 | 2001-04-18 09:29:52 |  row 4 : 6 | 2 | PPT | 1975-05-20 22:51:19 | 1992-05-02 20:06:11 |  row 5 : 7 | 8 | PPT | 1993-10-07 02:33:04 | 1975-07-16 04:52:10 |  row 6 : 8 | 3 | BK | 1983-07-16 21:16:16 | 1976-10-28 10:08:50 |  row 7 : 9 | 2 | BK | 1997-04-17 08:29:44 | 1994-12-07 13:26:23 |  row 8 : 10 | 1 | PPT | 2003-06-05 04:03:45 | 2007-06-06 06:18:53 |  row 9 : 11 | 6 | BK | 1996-02-04 11:27:24 | 1995-09-19 22:27:48 |  row 10 : 14 | 7 | AD | 1975-10-20 02:28:58 | 1979-11-04 08:58:39 |  row 11 : 15 | 9 | CV | 1986-12-09 14:51:36 | 1993-03-24 14:30:23 |  row 12 : 16 | 5 | CV | 2012-04-05 07:11:42 | 1980-05-07 12:15:47 |  row 13 : 18 | 5 | PP | 1984-08-07 13:36:26 | 1998-05-12 12:51:29 |  row 14 : 19 | 7 | AD | 1999-06-21 11:10:30 | 1974-09-14 06:34:39 |  row 15 : 20 | 6 | BK | 1986-11-14 12:20:18 | 2008-08-08 18:36:43 |  row 16 : 21 | 9 | AD | 2002-08-25 13:26:23 | 2015-09-06 01:08:44 |  row 17 : 22 | 0 | PP | 2005-02-20 00:31:34 | 1989-11-24 19:06:06 |  row 18 : 23 | 2 | BK | 1979-12-24 10:28:16 | 2000-10-22 11:57:12 |  row 19 : 24 | 8 | PP | 2008-08-01 13:57:26 | 1973-01-12 14:13:34 |  row 20 : 25 | 5 | PP | 1979-10-20 21:23:20 | 2006-02-06 23:52:04 | <table_name> : Templates col : Template_ID | Version_Number | Template_Type_Code | Date_Effective_From | Date_Effective_To | Template_Details row 1 : 0 | 5 | PP | 2005-11-12 07:09:48 | 2008-01-05 14:19:28 |  row 2 : 1 | 9 | PP | 2010-09-24 01:15:11 | 1999-07-08 03:31:04 |  row 3 : 4 | 4 | BK | 2002-03-02 14:39:49 | 2001-04-18 09:29:52 |  row 4 : 6 | 2 | PPT | 1975-05-20 22:51:19 | 1992-05-02 20:06:11 |  row 5 : 7 | 8 | PPT | 1993-10-07 02:33:04 | 1975-07-16 04:52:10 |  row 6 : 8 | 3 | BK | 1983-07-16 21:16:16 | 1976-10-28 10:08:50 |  row 7 : 9 | 2 | BK | 1997-04-17 08:29:44 | 1994-12-07 13:26:23 |  row 8 : 10 | 1 | PPT | 2003-06-05 04:03:45 | 2007-06-06 06:18:53 |  row 9 : 11 | 6 | BK | 1996-02-04 11:27:24 | 1995-09-19 22:27:48 |  row 10 : 14 | 7 | AD | 1975-10-20 02:28:58 | 1979-11-04 08:58:39 |  row 11 : 15 | 9 | CV | 1986-12-09 14:51:36 | 1993-03-24 14:30:23 |  row 12 : 16 | 5 | CV | 2012-04-05 07:11:42 | 1980-05-07 12:15:47 |  row 13 : 18 | 5 | PP | 1984-08-07 13:36:26 | 1998-05-12 12:51:29 |  row 14 : 19 | 7 | AD | 1999-06-21 11:10:30 | 1974-09-14 06:34:39 |  row 15 : 20 | 6 | BK | 1986-11-14 12:20:18 | 2008-08-08 18:36:43 |  row 16 : 21 | 9 | AD | 2002-08-25 13:26:23 | 2015-09-06 01:08:44 |  row 17 : 22 | 0 | PP | 2005-02-20 00:31:34 | 1989-11-24 19:06:06 |  row 18 : 23 | 2 | BK | 1979-12-24 10:28:16 | 2000-10-22 11:57:12 |  row 19 : 24 | 8 | PP | 2008-08-01 13:57:26 | 1973-01-12 14:13:34 |  row 20 : 25 | 5 | PP | 1979-10-20 21:23:20 | 2006-02-06 23:52:04 |
col : Template_Details | Template_Type_Code | Template_ID row 1 :  | BK | 4 row 2 :  | BK | 8 row 3 :  | BK | 9 row 4 :  | BK | 20 row 5 :  | BK | 23 row 6 :  | CV | 16 row 7 :  | PP | 0 row 8 :  | PP | 18 row 9 :  | PP | 22 row 10 :  | PP | 25 row 11 :  | PPT | 6 row 12 :  | PPT | 10