Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Unanswered: SQL: Select Case when ...

    Goal is to select data from a table ec_rates, but some conversion is needed to have the right data/column header in a csv file. I would like 1 row per market date and several columns for the government bond rate type (1Y, 2Y, ...), filled with the mid rate.

    Please see 2 lines of data from the table and what I would like

    rate_code market_date bid ask mid
    FR.EUR.GBY.0.0.1 2012-03-14 0.32 0.32 0.32
    FR.EUR.GBY.0.0.2 2012-03-14 0.681 0.681 0.681

    Goal:

    'market_date' needs to be converted into 'DATE'
    mid rate for 'FR.EUR.GBY.0.0.1' needs to be taken into the column 'EURFRGBOND1Y'
    mid rate for 'FR.EUR.GBY.0.0.2' needs to be taken into the column 'EURFRGBOND2Y'

    Report (where data for column 2+3 is the mid rate):
    DATE EURFRGBOND1Y EURFRGBOND2Y
    2012-03-14 0.32 0.681


    SELECT market_date as DATE,
    ...
    from ec_rates

    I've tried this:

    CASE WHEN (rate_code='FR.EUR.GBY.0.0.1') THEN mid else 0 end as EURFRGBOND1Y

    But I don't want all the 0 values, I only want to report the value per market_date and per rate_code
    Last edited by dEX2340; 03-15-12 at 10:18.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If this is an assignement, you need to give us more background on what you've covered in class.

    If this is a business problem, handle the formatting in your reporting package.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Mar 2012
    Posts
    2
    This is a business problem. But I don't exactly understand what you mean with "handle it in the reporting package"?

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    It's a display issue. You hand the data off to your UI (be that a reporting package such as Crystal Reports or a custom application or webpage) and that's where you display it in the way you want.
    George
    Home | Blog

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Exactly as gvee put it... This is a presentation issue not a data storage or management issue, so the presentation layer (like SSRS or Crystal Reports) is where that presentation ought to be managed.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •