SELECT COUNT ( DISTINCT subject_name ) FROM SUBJECT WHERE \"_kp_subject_id\" = \"INFORMATION::_kf_subject_id\"
" ; "" ; "" )
with no luck?
SELECT COUNT(subject_name) FROM SUBJECT
WHERE \"_kp_subject_id\" = ?";
does not produce result I don't understand why?
Do I need an extra Table Occurrence to work with the above result?
Are you getting the wrong answer or the dreaded "?" result?
Is Subject_Name unique to each record in Subject?
Is this your relationship?
Subject::_kp_Subject_id = Information::_kf_Subject_id
If so and if your SQL query does not throw a syntax error (?) then I would expect your query to return a count of 1 as there should be only one record in Subject with a given Subject_id value.
SELECT Count ( * ) From /"Subject/"
would count all records in Subject. A "count of" summary field, if referenced from the correct context, can return the same result.
Yes my relation ship is Subject---------<Information. Yes I am getting ?. I wan to count the information in a Subject. And get back a number. I guess I have twisted it all up.
Actually when written like this it does not return a ? I have it un-stored. I want to return the number of pieces of information for a given Subject and I am trying to represent in on the Subject Layout. I just get an empty field.
SELECT Count ( * ) From /"Subject/" is where I always started but I want it to only count the pieces of information for that subject.
Are you counting records in Subject or Information?
The SQL that I suggested counts the number of records in Subject. If you want the number of related Information records for a given subject record, all you need is:
Count ( Information::_kf_subject_id )
Do I need a table orrurence wiith that as well?
No. The table occurrence that you choose determines what relationship is used to match records for the count. The one you have in place that matches by subject ID will match to the correct set of records.
To learn more about table occurrences and how to use them: Tutorial: What are Table Occurrences?
Your advise worked extremely well and I learned a lot thanks