Results 1 to 4 of 4

Thread: sql query help

  1. #1
    Join Date
    Jan 2010
    Posts
    29

    Unanswered: sql query help

    hi

    i am completely new to sql query,i have a question while writing sql query

    I have a table called PDBDETL,in that i have ddpdst column

    how to write a query to get below values

    1.POLICY_FEE=PDBDETL.DDFEPD
    2.SERVICE_CHARGES=PDBDETL.ddpdst in ( INS,IN1,IN ,RRB,RNB )
    3.REINSTATEMENT_FEES=PDBDETL.ddpdst = 'RLP'
    4.RETURNED_CHECK_FEE=PDBDETL.ddpdst = 'NSF'
    5.OTHER_FEES=other code not listed policy fees and sevice charges

    and i need to join this table to other

    please help me

    Thanks in advance!!

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >and i need to join this table to other
    >I have a table called PDBDETL
    If PDBDETL is "this" table, what is name of "other" table?

    Post results from

    DESCRIBE PDBDETL
    DESCRIBE <other_table>

    How will you determine if SQL produces correct/desired results?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    Well you win the vague question of the day award. Congrats!

    We have no clue what you have or what you are trying to do. But here is something that MAY get you going.
    Code:
    SELECT d.policy_number,
      SUM(CASE WHEN ddpdst IN ('INS','IN1','IN','RRB','RNB') 
        THEN d.ammount END) AS service_charges,
      SUM(CASE WHEN ddpdst = 'RLP' THEN d.ammount END) AS reinstatement_fees,
      SUM(CASE WHEN ddpdst = 'NSF' THEN d.ammount END) AS returned_check_fees,
      SUM(CASE WHEN ddpdst NOT IN ('INS','IN1','IN','RRB','RNB','RLP','NSF') 
        THEN d.ammount END) AS other_fees
    FROM pdbdetl d
    GROUP BY d.policy_number

  4. #4
    Join Date
    Jan 2010
    Posts
    29
    hi artascus

    query is really useful,thanks for your reply
    Last edited by hasya05; 04-22-10 at 14:18.

Posting Permissions

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