FileMaker: How to auto-fill field in a new record with value from different field in previous record - filemaker

FileMaker Pro Version 11. Two fields of interest in a record: Let's call them start_value and end_value.
When creating a new record I want start_value to be auto-filled with end_value from the previous record (which should be the highest end_value in the table).
I am an old-time C coder, this is my first FileMaker attempt, so be gentle with me. :-)

My last answer was insane . I worked through your problem and found a working solution.
Create a new field maxvalue(Field type = summary ).
.A prompt shows you to find maximum value via checkbox Maximum then Select end_value field
Goto start_value field->field options->auto-enter
Check Calculated value
click specify and write 'maxvalue' without quotes

You can use a cartesian self-relationship and add Auto-Enter calculation to the start_value field definition to be Max(end_value). Max(end_value) have to refer to the related field and not the local one.
===
Added some instructions:
Open Define Database and select the Table Occurrence of the table where fields start_value and end_value are. You can also add another table occurrence of this table for the calculation. Let's call it MyTable.
Duplicate MyTable and give it a name, e.g. MyTable_self
Create a relationship MyTable to MyTable_self, by any field will be fine, but preferably by Primary Key.
Open "Edit Relationship" and change the relationship type from join (=) to cartesian ( x ).
Open the filed definition for start_value in MyTable.
Change Auto-Enter options to "Calculated Value" and add formula
Max(MyTable_self::end_value)
The context of calculations has to be "MyTable"

Related

How to save a query result into a column using postgresql

This may be a simple fix but Im somehow drawing a blank. I have this code below, and I want the results that I got from it to be added into their own column in an existing table. How would i go about doing this.
Select full_name, SUM(total) as sum_sales
FROM loyalty
where invoiceyear = 2013
GROUP BY full_name
order by sum_sales DESC;
This leaves me with one column with the name of employee and the second with their sales from that year.
How can i just take these results and add them into a column in addition to the table
Is it as simple as...
Alter table loyalty
Add column "2013 sales"
and then add in some sort of condition?
Any help would be greatly appreciated!
If i got your question right, you need to first alter the table allowing the new field to be null (you can change it later on) then you could use an insert clause to store the value permanently.

How to Link 2 Sheets that have the same fields

I am looking for some help with trying to link 2 sheets that have a number of Filters that I have setup but are both sitting in separate tables. The reason this is because I have a number of aggregated columns that are different for the 2 tables and want to keep this separately as I will be building more sheets as I go along.
The filters that are the same within the 2 sheets are the following:
we_date
product
manager
patch
Through the data manager I managed to create an association between the 2 tables for we_date but from reading on this site and other searches on Google I can't make any associations between these tables and this is where I am stuck.
The 2 sheets will now allow me to filter using the we_date, but if I use the filters for product, manager or patch then nothing happens on my 2nd sheet as they are not linked.
Currently in my data load editor I have 2 sections of select queries like the following:
Table1
QUALIFY *;
w:
SELECT
*
FROM
table1
;
UNQUALIFY *;
Table2
QUALIFY *;
w_c:
SELECT
*
FROM
table2
;
UNQUALIFY *;
I would really appreciate if somebody could advise a fix on the issue I am having.
In Qlik, field names of identical values from different tables are automatically associated.
When you're calling Qualify *, you're actually renaming all field names and explicitly saying NOT to associate.
Take a look at the Qlik Sense documentation on Qualify *:
The automatic join between fields with the same name in different
tables can be suspended by means of the qualify statement, which
qualifies the field name with its table name. If qualified, the field
name(s) will be renamed when found in a table. The new name will be in
the form of tablename.fieldname. Tablename is equivalent to the label
of the current table, or, if no label exists, to the name appearing
after from in LOAD and SELECT statements.
We can use as to manually reassign field names.
SELECT customer_id, private_info as "private_info_1", favorite_dog from table1;
SELECT customer_id, private_info as "private_info_2", car from table2;
Or, we can correctly use Qualify. Example:
table1 and table2 have a customer_id field, and private_info field. We want customer_id field to be the associative value, and private_info to not be. We would use QUALIFY on private_info, which Qlik would then rename based on file name.
QUALIFY private_info;
SELECT * from table1;
SELECT * from table2;
The following field names would then be: customer_id (associated), and table1.private_info, and table2.private_info

How to add two or more column in third column in SQL server 2008

For Example
Roll No, Name, Maths, English, Total(Maths+English)
You can use a computed column. Assuming columns Maths and English are a numeric type, you can do like so:
ALTER TABLE [MyTable] ADD Total AS Maths + English;
Once created, you access the column (read only, obviously) as you would any other column, i.e.
select English, Maths, Total from [MyTable];
SELECT Roll No, Name, Maths, English, Maths+English AS TOTAL
FROM [YOUR TABLE]
You need to assign the Total column a function
go to the table in design view mode, then click on Total column (I assume
you already have this column, if not create it first, and then click on it in design view)
then from column properties expand 'Computer Column Specification'
then in forumula field write:
(Maths+English)

Dynamic progressive select in abap

I would create in Abap a dynamic progressive select in a db table.
Es:
(1) my table has 4 key field;
(2) the first select is with all 4 key;
(3) if i don't find a record -> second select with first 3 key fields;
(4) if i don't find a record -> third select with first 2 key fields;
(5) if i don't find a record -> fourth select with only first key field;
(6) if i don't find a record -> raise error.
I must use field symbols, but how? Can you help me about implementation of selects?
Thanks
Pseudocode of a naive approach:
SELECT INTO TABLE with all four fields.
IF sy-dbcnt = 0.
SELECT INTO TABLE with three fields.
IF sy-dbcnt = 0.
SELECT INTO TABLE with two fields.
IF sy-dbcnt = 0.
SELECT INTO TABLE with one field.
IF sy-dbcnt = 0.
MESSAGE TYPE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
LOOP AT table ASSIGNING <field_symbol>.
"do something with the table line in the field symbol
ENDLOOP.

T-SQL LEFT JOIN on bigint id return only ids lower than 101 on right table

I have two tables on a Sql Server 2008.
ownership with 3 fields and case with another 3 fields I need to join both on the ID field (bigint).
For testing purposes I'm only using one field from each table. This field is bigint and has values from 1 to 170 (for now).
My query is:
SELECT DISTINCT
ownership.fCase,
case.id
FROM
ownership LEFT JOIN case ON (case.id=ownership.fCase)
WHERE
ownership.dUser='demo'
This was expected to return 4 rows with the same values on both columns. Problem is that the last row of the right table comes as null for the fCase = 140. This is the only value above 100.
If I run the query without the WHERE clause it show all rows on the left table but the values on the right only apear if below 101 otherwise shows null.
Can someone help me, am I doing something wrong or is this a limitation or a bug?
Case is also a verb so it may be getting confused. Try your table and column names in []. E.G. [case].[id] = [ownership].[fCase]. Are you like double check sure that [case].[id] and [ownership].[fCase] are both bigint. If your current values are 1-170 then why bigint (9,223,372,036,854,775,807)? Does that column accept nulls?