Loading ...
Sorry, an error occurred while loading the content.

RE: [SQLQueriesNoCode] Can any one tell me this query?

Expand Messages
  • Dave May
    You didn t specify which RDBMS you are using, but if using SQLServer the solution is very straightforward. Lookup datediff in BOL for more information. select
    Message 1 of 17 , Jan 30, 2006
    • 0 Attachment
      You didn't specify which RDBMS you are using, but if using SQLServer the
      solution is very straightforward. Lookup datediff in BOL for more
      information.

      select datediff(day, '11-15-2005', '05-15-2006')
      select datediff(day, '11-15-2005', '01-27-2006')

      Dave.

      -----Original Message-----
      From: SQLQueriesNoCode@yahoogroups.com
      [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Virtual Fission
      Sent: Monday, January 30, 2006 8:05 PM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: RE: [SQLQueriesNoCode] Can any one tell me this query?


      Hi

      I am given a date and maturity as in 01-27-2006 and
      05/15/2030

      I must compute the number of days between 11-15-2005
      and
      05-15-2006
      and the number of days between 11-15-2005 and
      01-27-2006.

      If anyone has any ideas how I might go about doing
      this
      please advise.

      Thank you
      --
      vF



      Yahoo! Groups Links
    • Rehan Mirza
      Hi, This is Rehan Mirza from Karachi, Pakistan. you use Select DateCol1 - DateCol2 From TableName; Select 15-May-06 - 15-Nov-05 From TableName; I mean you
      Message 2 of 17 , Jan 31, 2006
      • 0 Attachment
        Hi,

        This is Rehan Mirza from Karachi, Pakistan.

        you use

        Select DateCol1 - DateCol2
        From TableName;

        Select '15-May-06' - '15-Nov-05'
        From TableName;

        I mean you use date minus '-' date to obtain number or
        days

        for example
        '17-Jan-06' - '15-Jan-06' = 2
        '15-Jan-06' - '17-Jan-06' = -2

        Thanks


        Message: 8
        Date: Mon, 30 Jan 2006 20:40:07 -0500
        From: Dave May <dave.may@...>
        Subject: RE: Can any one tell me this query?

        You didn't specify which RDBMS you are using, but if
        using SQLServer
        the
        solution is very straightforward. Lookup datediff in
        BOL for more
        information.

        select datediff(day, '11-15-2005', '05-15-2006')
        select datediff(day, '11-15-2005', '01-27-2006')

        Dave.

        -----Original Message-----
        From: SQLQueriesNoCode@yahoogroups.com
        [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of
        Virtual Fission
        Sent: Monday, January 30, 2006 8:05 PM
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: RE: [SQLQueriesNoCode] Can any one tell me
        this query?


        Hi

        I am given a date and maturity as in 01-27-2006 and
        05/15/2030

        I must compute the number of days between 11-15-2005
        and
        05-15-2006
        and the number of days between 11-15-2005 and
        01-27-2006.

        If anyone has any ideas how I might go about doing
        this
        please advise.

        Thank you
        --
        vF

        When ever you pray
        please remember me and my parents.

        Regards,
        Rehan Mirza

        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail.yahoo.com
      • Derek Paul
        I have 2 tables each with three columns: Table1 loanNo AccFee1 AccFee2 Table2 LOAN_NUM ACC_FEE_1 ACC_FEE_2 LoanNo & LOAN_NUM in each table matches What I m
        Message 3 of 17 , Jul 12, 2007
        • 0 Attachment
          I have 2 tables each with three columns:



          Table1

          loanNo

          AccFee1

          AccFee2



          Table2

          LOAN_NUM

          ACC_FEE_1

          ACC_FEE_2



          LoanNo & LOAN_NUM in each table matches



          What I'm trying to return is a list where:

          AccFee1 doesn't match ACC_FEE_1 AND AccFee2 doesn't match ACC_FEE_2

          AccFee1 doesn't match ACC_FEE_1 BUT AccFee2 does match ACC_FEE_2

          AccFee1 does match ACC_FEE_1 BUT AccFee2 doesn't match ACC_FEE_2



          I can create a view which return the list if AccFee1 doesn't match
          ACC_FEE_1 AND AccFee2 doesn't match ACC_FEE_2, but if I change the
          data so one of the fields match, it then doesn't return...



          Thanx in advance



          Cheers,

          Derek PAUL



          The information transmitted by this e-mail is intended only
          for the addressee and may contain confidential and/or
          privileged material. Any interception, review, retransmission,
          dissemination, or other use of, or taking of any action upon
          this information by persons or entities other than the
          intended recipient is prohibited by law and may subject them
          to criminal or civil liability.
          Unless explicitly attributed, the opinions expressed are personal
          and not those of HomeStart or the South Australian Government.
          If you received this communication
          in error, please contact us immediately at
          admin@..., and delete the communication.



          [Non-text portions of this message have been removed]
        • Arnie Rowland
          Derek, The example below may be the tactic to use. Often you will get quicker and better responses if you include in your post the table DDL and some sample
          Message 4 of 17 , Jul 13, 2007
          • 0 Attachment
            Derek,

            The example below may be the tactic to use.

            Often you will get quicker and better responses if you include in your post
            the table DDL and some sample data in the form of INSERT statements -very
            similar to the code below. That makes it easy for folks to try to help you
            since all they have to do is try their ideas. Without the DDL and data,
            since few of us and do these kind of things 'just off the top of our head',
            one must take the time to create them and that will reduce the potential
            responses.

            Regards,

            - Arnie Rowland, MCT, MVP (SQL Server)

            "I am a great believer in luck, and I find that the harder I work, the more
            I have of it." - Thomas Jefferson (1743-1826)

            -----Original Message-----
            From: SQLQueriesNoCode@yahoogroups.com
            [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Derek Paul
            Sent: Friday, July 13, 2007 9:51 AM
            To: Arnie
            Subject: [SQLQueriesNoCode] Can any one help me with a query?

            SET NOCOUNT ON

            DECLARE @MyTable1 table
            ( RowID int IDENTITY,
            LoanNo int,
            AccFee1 money,
            AccFee2 money
            )

            DECLARE @MyTable2 table
            ( RowID int IDENTITY,
            Loan_Num int,
            Acc_Fee_1 money,
            Acc_Fee_2 money
            )

            INSERT INTO @MyTable1 VALUES ( 101, 5, 5 )
            INSERT INTO @MyTable1 VALUES ( 102, 5.25, 7.5 )
            INSERT INTO @MyTable1 VALUES ( 103, 4.5, 5 )
            INSERT INTO @MyTable1 VALUES ( 104, 9.5, 10.5 )

            INSERT INTO @MyTable2 VALUES ( 101, 5, 5 )
            INSERT INTO @MyTable2 VALUES ( 102, 5.75, 7.5 )
            INSERT INTO @MyTable2 VALUES ( 103, 4.5, 8.5 )
            INSERT INTO @MyTable2 VALUES ( 104, 3.5, 2.5 )

            SELECT
            'Table1',
            t1.LoanNo,
            t1.AccFee1,
            t1.AccFee2,
            'Table2',
            t2.Loan_Num,
            t2.Acc_Fee_1,
            t2.Acc_Fee_2
            FROM @MyTable1 t1
            JOIN @MyTable2 t2
            ON ( t1.LoanNo = t2.Loan_Num
            AND ( t1.AccFee1 <> t2.Acc_Fee_1
            OR t1.AccFee2 <> t2.Acc_Fee_2
            )
            )


            LoanNo AccFee1 AccFee2 Loan_Num Acc_Fee_1 Acc_Fee_2

            ------ ------ -------- -------- ------ -------- --------- ---------
            Table1 102 5.2500 7.5000 Table2 102 5.7500 7.5000
            Table1 103 4.5000 5.0000 Table2 103 4.5000 8.5000
            Table1 104 9.5000 10.5000 Table2 104 3.5000 2.5000


            Disclaimer - July 13, 2007
            This email and any files transmitted with it are confidential and intended solely for SQLQueriesNoCode@yahoogroups.com. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Westwood Consulting, Inc. Warning: Although Westwood Consulting, Inc has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.
            This disclaimer was added by Policy Patrol: http://www.policypatrol.com/


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.