• 0

# Select sum

## Question

Hi all,

Whats wrong with this code?

SELECT sum(Teller) FROM K_Schadekenmerken_Data WHERE OfferteNR = target.[@field:OfferteNR]

Greatings from the Netherlands

## Recommended Posts

• 0

Hi @wvantongeren,

Your formula seems to be correct, what error message are you getting?
If your 'K_Schadekenmerken_Data '  source is a view and not a table, kindly use the code below instead.

`SELECT sum(Teller) FROM _v_K_Schadekenmerken_Data WHERE OfferteNR = target.[@field:OfferteNR]`

And if your 'K_Schadekenmerken_Data' source is a table, kindly provide us a screenshot of the table structure/design of this table so that we can further assist you with this,

Regards,

TsiBiRu

##### Share on other sites

• 0

I have the same formula in my DataPage.

You need to make sure if the "Teller" is on Number or Integer or even Currency DataType, and make sure that you are selecting the correct Column Name and Table name as well.

Hope this helps.

##### Share on other sites

• 0

Also make sure to add a group by clause if there are multiple records containing the same ID. Is OffertNR an ID field? If it is then try the following:

SELECT sum(Teller) FROM K_Schadekenmerken_Data WHERE OfferteNR = target.[@field:OfferteNR] group by OfferteNR

For examples, check out https://www.w3schools.com/sql/sql_groupby.asp.

##### Share on other sites

• 0
```Hi,
Nothing works!
Previously, I applied this to other DataPages:
SELECT (Artikelprijs) FROM Betontechniek_Bonnen_Producten  WHERE Artikelnummer = 4000
And
SELECT SUM (Werk_uren) FROM Beton_Bonnen_Daguren_1 WHERE Werknummer = target.[@field:Klus_Werknr]```

It's still working.

If I change the last code (I want to count how much rows ther are with the same OfferteNR) in:

SELECT SUM (Teller) FROM K_Schadekenmerken_Data  WHERE OfferteNR = target.[@field:OfferteNR]

it does not work, see a piece of my table and error message.

##### Share on other sites

• 0

Hi there!

I noticed the error there saying "Invalid column name 'OfferteNR'".

I just want to verify, do you have a field "[@field:OfferteNR]" inside the DataSource?

As the error says, it has something to do with the Column Name.

I also noticed that you are using a View. You should atleast have the field OfferteNR in it.

I know this sounds like a crazy assumption but I tried replicating the error on my end, and the error occurs when I don't have the field on my DataSource, since I have no field to compare it to.

Please check out the formula I tried:

http://prntscr.com/mtrkdi

If this is not the case, can you please specify what are the DataTypes of the field you are selecting? "Teller" and "OfferteNR".

##### Share on other sites

• 0

Hi Vanallope,

I solved my problem

I was counting with text instead of numbers, stupid.

Don't try to smile

##### Share on other sites

• 0

I sometimes do the same mistake

##### Share on other sites

• 0

Is Teller a Number field or a text field? It has to be a number type in your table.  Is " K_Schadekenmerken_Dat﻿a " a table or a view? If it is a view you need to add "_v_" in front of the name for instance: _v_ K_Schadekenmerken_Dat﻿a

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.