Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8158625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:40:03+00:00 2026-06-06T17:40:03+00:00

Lets say i have a table with the following data Customer table: Name amount

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:40:05+00:00Added an answer on June 6, 2026 at 5:40 pm

    The Oracle syntax to do what you describe in your two bullet-points would be

    SELECT (CASE WHEN     date_created >= trunc(sysdate,'Q') 
                      AND date_created < trunc(add_months(sysdate,3),'Q')
                 THEN name || '-' || invoice_number
                 ELSE name
             END),
           date_created, 
           invoice_number
      FROM Customer;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Lets say I have a table with some data like the following: ID text
I have the following mysql table called test. lets say it has the data
Let's say I have a table containing following data: | id | t0 |
Let's say i have a table with the following data: day1 item1 30 day1
Lets say I have table with following columns 1. Client - string. 2. Profit
Lets say I have a table with the following columns: Qty, INTEGER SaleDate, DATETIME
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)
Let's say I have the following data in the Customers table: (nothing more) ID
Lets say we have the following: create view view_1 as ( select key, data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.