Lets say i have a table with the following data

Customer table:

```
Name      amount    date_created    invoice_number
--------------------------------------------------
John     50         11April2012          12
Bob      150        15April2012          32
David    506        10May2012            52
Paul     80         12Aug2012            12
Mark     10         11Jan2012            52

```

Summary table:

```
Name        amount  
---------------------
Sally       250 
Darren-32   150 

```

I would like to select all the rows where date\_created is between the start\_date and end\_date of the current\_quarter. If date\_created is within the current quarter i would like to append the invoice\_number to the name before doing the insert statement (See example in the summary table above). 

```
INSERT summary(name, amount)
SELECT name|| '-' || invoice_number, date_created, invoice_number
From Customer;

```

* How can i modify the above to use either "Decode" function or a "Case" function (or any other "IF statement" type function) to check the value of date\_created and append invoice\_number if date\_created is within the current quarter.
* Obviously i will need to know the start and end dates of the current quarter and will need to store them somewhere before doing the comparison. Is this possible at all with pure SQL? PL/SQL is not an option.

Assuming we are in Q1 (Apr - Jun) the end result should be:

```
Name        amount  
---------------------
Sally       250 
Darren-32   150
John-12     50
Bob-32      150
David-52    506
Paul        80
Mark        10

```

I am reading the Customer table from an Oracle 10G database and populating the summary into a "Summary" table which resides in a SQL server database. The fact that i am inserting into an SQL Server database should not really matter. I am reading the data from an Oracle database so the syntax should be Oracle compatible.