# Selecting stored calc in .getDatasetByQuery

**URL:** <https://forum.servoy.com/t/selecting-stored-calc-in-getdatasetbyquery/7835>\
**Category:** Classic Servoy\
**Created:** [July 17, 2007, 8:19pm UTC](https://forum.servoy.com/t/selecting-stored-calc-in-getdatasetbyquery/7835 "2007-07-17T20:19:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSharp](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@JSharp](https://forum.servoy.com/u/JSharp)\
**Post date:** [July 17, 2007, 8:19pm UTC](https://forum.servoy.com/t/selecting-stored-calc-in-getdatasetbyquery/7835/1 "2007-07-17T20:19:31Z")

</div>

Hi all,

I am trying to extract a set of fullname calculations to use as display values in a valuelist. I have the problem that I can not seem to grab the calculated values with my sql query but can select other dataproviders.

```auto
SELECT DISTINCT n.fullnameb, c.contact_id FROM contact c INNER JOIN names n ON c.name_id = n.name_id WHERE c.caregiver_id='" + globals.gContactID + "'";

```

“fullnameb” is also a calculation on the names table.

```auto
var fullname = "";
if(title != null) {
	fullname += names_to_title.title
}
if(fname != null && fname != "") {
	fname + " ";
}
if(mi != null && mi != "") {
	fullname += mi + " ";
}
if(lname != null && lname != "") {
	fullname += lname + " ";
}
if(suffix != null) {
	fullname += names_to_suffices.suffix;
}
return fullname;

```

Prior to calling .getDatasetByQuery() I call:

```auto
databaseManager.recalculate(forms.names.foundset);
databaseManager.refreshRecordFromDatabase(forms.names.foundset, -1);

```

However, I keep getting null values returned in my dataset, while if I select n.fname I get the first names.

Am I missing something?

Jon

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [July 17, 2007, 8:27pm UTC](https://forum.servoy.com/t/selecting-stored-calc-in-getdatasetbyquery/7835/2 "2007-07-17T20:27:18Z")

</div>

> JSharp:
> 
> ```auto
> SELECT DISTINCT n.fullnameb, c.contact_id FROM contact c INNER JOIN names n ON c.name_id = n.name_id WHERE c.caregiver_id='" + globals.gContactID + "'";
> 
> ```

Just from the top of my head: you are only selecting from the table called “contacts” but your fullnameb is on table “names”, try:

```auto
SELECT DISTINCT n.fullnameb, c.contact_id FROM contact, names c INNER JOIN names n ON c.name_id = n.name_id WHERE c.caregiver_id='" + globals.gContactID + "'";

```

It should work as long as the calculation is a stored one.
