How do delete certain lines alone which are matching with start and end string values in file?

Hi, In my previous post ( How to print lines from a files with specific start and end patterns and pick only the last lines? ), i have got a help to get the last select statement from a file, now i need to remove/exclude the output from main file:

Input File format:
SELECT  
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test1
limit 1;

delete from test2;

SELECT  ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test1
limit 1;

create table as SELECT  
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test1
limit 1;

SELECT  ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test1
limit 1;


SELECT 
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test1
limit 1;

SELECT  
ABCD,
DEFGH,
from test1
limit 1;

delete from test2;

create table as SELECT  
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test1345
limit 1;

create table as SELECT  ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,
DFVBNM,
QWER,
RTU,
TYUI,
IOPL from test123
limit 1;
Input Format 2 ( which is the output of command ) awk '$1=="SELECT"{s=$0} END{if(s) print s}' RS= file


SELECT  
ABCD,
DEFGH,
from test1
limit 1;

OUTPUT Format should be INPUT Format - Input Format 2 ( only input format exact lines from 'select' to ';' should be removed from Input format.

Hi,

The UNIX and Linux Forums are a tech site to help you administrator your computer(s) and to help you write your own scripts. We are not here to write your scripts for you.

Please post your work, the scripts you have written, any error messages you saw, etc.

Thanks.

Also this question has already been answered in thread: https://www.unix.com/unix-for-beginners-questions-and-answers/282910-how-print-lines-files-specific-start-end-patterns-pick-only-last-lines.html\#post303040014