I need help figuring out how to use SELECT DISTINCT (or something similar) in a calculated field in a datapage based on a view. I am mostly unfamiliar with SQL and can't figure out how to implement the syntax.
Datapage is based on a 3-table view "LocusArtifactFragment" where Locus is parent table, Artifact is child1 (one-to-many relationship with parent Locus), and Fragment is Child2 (one-to-many relationship with parent Artifact). I want to count distinct related records from Parent (Locus) in both related tables in the view (Artifact = Child1 AND Fragment = Child2). The view includes columns for LocusID, ArtifactID, and FragmentID (pk in each table) plus the foreign keys that make the relationships.
I can easily count related records of fragments by counting FragmentID, but I need to count Distinct Artifact ID (because if I just count Artifact ID, I get equal numbers of fragmentID and artifactID, since artifactID appears for every related record in Fragment). This syntax from the howto site seems like it is more or less what I need, but I can't get it functional when I sub in my field and view names: "SELECT Count(Country) FROM Customers WHERE Country=’Canada’"
Any thoughts on how to implement this would be very welcome. I need to verify students' data entry is correct and complete before moving forward with other parts of the project. Many thanks.
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.
Question
Allison
I need help figuring out how to use SELECT DISTINCT (or something similar) in a calculated field in a datapage based on a view. I am mostly unfamiliar with SQL and can't figure out how to implement the syntax.
Datapage is based on a 3-table view "LocusArtifactFragment" where Locus is parent table, Artifact is child1 (one-to-many relationship with parent Locus), and Fragment is Child2 (one-to-many relationship with parent Artifact). I want to count distinct related records from Parent (Locus) in both related tables in the view (Artifact = Child1 AND Fragment = Child2). The view includes columns for LocusID, ArtifactID, and FragmentID (pk in each table) plus the foreign keys that make the relationships.
I can easily count related records of fragments by counting FragmentID, but I need to count Distinct Artifact ID (because if I just count Artifact ID, I get equal numbers of fragmentID and artifactID, since artifactID appears for every related record in Fragment). This syntax from the howto site seems like it is more or less what I need, but I can't get it functional when I sub in my field and view names: "SELECT Count(Country) FROM Customers WHERE Country=’Canada’"
Any thoughts on how to implement this would be very welcome. I need to verify students' data entry is correct and complete before moving forward with other parts of the project. Many thanks.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
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.