Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:27:56+00:00 2026-06-16T06:27:56+00:00

I need your help in the following situation if is possible: I use Sql

  • 0

I need your help in the following situation if is possible:
I use Sql Server 2008 R2 and I have this table:

create table tblContracts 
([ContractID] [int] NOT NULL,
[PlotNumber] [nvarchar](150) NOT NULL,
[TotalArea] [numeric](12, 0) NULL,
[NotaryCosts] [numeric](12, 2) NULL,
[LandTax] [numeric](12, 2) NULL,
[OtherTaxes] [numeric](12, 2) NULL)

In this table I could have several records with the same ContractID but with different PlotNumber.
I want to dinamically split the costs for each PlotNumber depending on TotalArea where ContractID is the same.

For e.g. if I have next records:

1. ContractID=1,PlotNumber=1,TotalArea=100,NotaryCosts=300,LandTax=10,OtherTaxes=0 and
2. ContractID=1,PlotNumber=2,TotalArea=200,NotaryCosts=?,LandTax=20,OtherTaxes=0 

The formula for NotaryCosts should update itself dynamically according to the next formula:

NotaryCosts(for each PlotNumber)=sum(NotaryCosts with the same ContractID)/sum(TotalArea with the same ContractID)*TotalArea(for the specific PlotNumber)

It is possible to do this somehow?
Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:27:57+00:00Added an answer on June 16, 2026 at 6:27 am

    I pretty much agree with Thomas, I think the table design needs some work as well as how data is being entered into the system. At any rate here is a query that could be used as view to give you the calculated total you are look for or could be used in an Update statement. To do this automatically this logic would need to be placed in a trigger

    select
    tc.ContractID
    ,tc.PlotNumber
    ,tc.TotalArea 
    ,tc.TotalArea *tcTotals.Cost_Per_Area as [Notary_Cost]
    ,tc.LandTax
    ,tc.OtherTaxes 
    from
    tblContracts  tc
    inner join
    (
    select 
    ContractID
    ,SUM(notaryCosts) as [sum_NotaryCost]
    ,SUM(TotalArea) as [sum_TotalArea]
    ,SUM(notaryCosts)/SUM(TotalArea) as [Cost_Per_Area]
    from 
    tblContracts
    group by
    ContractID
    ) tcTotals
    on
    tc.ContractID =tcTotals.ContractID 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need your help in following case. i have table ChartData in that table
Hi and thanks for your help. I have the following situation. My Activity is
I need your help in solving the following 2 functions/problems: 1) I have to
Need your help. I am trying it first time. I have used following code.
I need your help !!!! I want to connect to sql server from a
I am just starting to learn js and need your help. I have following
I need your help in the following situation: I'm developing an app with a
I need your help in JAVA (with some sample code if possible) regarding to
I need your help with some sample code for a situation I could not
I need your help. Say I have a code inside a for statement similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.