Results 1 to 3 of 3

Thread: help on sql using command

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    138

    help on sql using command

    I'm writing a crystal report using command.

    I have 2 tables that needs to be extracted. I'm extraction field deal_no,action_dt from table events and posn_dt from table posnrpt


    Table Name:events
    field: deal_no, action_dt

    Table Name: posnrpt
    field: posn_dt

    Below are my records from table events in sql database


    deal_no|action_dt|posn_dt
    33|2011-12-23 00:00:00.000|2010-03-31 00:00:00.000
    33|2012-03-23 00:00:00.000|2010-03-31 00:00:00.000
    33|2012-03-23 00:00:00.000|2010-03-31 00:00:00.000
    34|2010-09-28 00:00:00.000|2010-04-08 00:00:00.000
    34|2012-09-28 00:00:00.000|2010-04-12 00:00:00.000
    34|2013-09-28 00:00:00.000|2010-04-12 00:00:00.000

    For example my posnrpt.posn_dt is "21/03/2012" and I'm trying to extract data from both table that
    display deal no with action date closest to posn_dt="21/03/2012" which must be greater or equal.

    my output should be like below

    deal_no action_dt posn_dt
    33 2012-03-23 00:00:00.000 2010-03-31 00:00:00.000
    34 2012-09-28 00:00:00.000 2010-04-12 00:00:00.000

    Note: I had to rewrite the problem again since it was not clear in the beginning. Hopefully this one clear the clouds. Thanks hack for moving this thread to the right location.
    Last edited by mizee; Apr 15th, 2010 at 09:34 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width