Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Location
    Bangalore
    Posts
    2

    Unanswered: using Computed Column in the Query

    need help ,

    i have a table called "Loans" where i need to compute a column i.e. NoofDays based on which other calculation like interest calculation needs to be done.
    my query goes like this

    "select datediff(dd,VDate, MDate) as NoOfDays ,NoOfDays * Principal * Rate /100 * 365 from Loans".

    if i run the above query it says

    "Invalid column name 'NoOfDays'".

    this executes fine if i use Access but not in SQL Server.

    can anybody say what might be the problem and how i can solve it.

    regards

    Rajesh

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    select datediff(dd,VDate, MDate) as NoOfDays ,datediff(dd,VDate, MDate) * Principal * Rate /100 * 365 from Loans

    OR

    select q.NoOfDays,q.NoOfDays * q.Principal * q.Rate /100 * 365
    (select datediff(dd,VDate, MDate),Principal,Rate from Loans) as q

Posting Permissions

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