Raul, Each col in the select clause need an aggregation function. If I do that (note 2 occurences of count), then your statement works: jd'reads count p.PATIENTID, LASTNAME: count p.LASTNAME, first v.VISIT_DATE by p.PATIENTID from p:patients, v:p.visits'
On Thu, Feb 10, 2022 at 2:41 PM Eric Iverson <eric.b.iver...@gmail.com> wrote: > Take a look at https://code.jsoftware.com/wiki/Jd if you have not already > done so. > > The docs are weak and we depend more on the tutorials. There are tutorials > that cover the area you are interested in. > > I loaded your files and have taken a quick look. > > First, I removed all the col relabel stuff as it is noise (and at times in > the past has triggered bugs). That is, remove all the txt: and other stuff > to make the statement as simple as possible. > > The by clause requires that there be an aggregation function for each col > in the select clause. That is the important part you were missing, although > the error was quite misleading. > > The following is a simple statement that works and has all the important > elements from your example. > > > jd'reads count patients.LASTNAME , count visits.VISIT_DATE by > patients.PATIENTID from patients, patients.visits' > > Perhaps it will help you get further along. > > If you get stuck again or are still stuck, please ask again. > > On Thu, Feb 10, 2022 at 2:12 PM Raul Miller <rauldmil...@gmail.com> wrote: > >> Embarrassing mis-statement: >> >> I wrote: "I am not trying to learn Jd" >> >> I meant: I am *now* trying to learn Jd >> >> -- >> Raul >> >> On Thu, Feb 10, 2022 at 1:58 PM Raul Miller <rauldmil...@gmail.com> >> wrote: >> > >> > http://rosettacode.org/wiki/Merge_and_aggregate_datasets >> > >> > After looking at this rosettacode task, I decided that Jd is probably >> > best suited for the J task implementation. So, I am not trying to >> > learn Jd (I had not had occasion to use it, previously). >> > >> > After a few minor mishaps, I've stumbled on an issue which I do not >> > know how to resolve. >> > >> > (Previous mishaps: csvload fails with an error suggesting that the >> > file does not exist if csvprepare has not been previously run. This >> > behavior is undocumented, except by example in the tutorials. Also, I >> > need to run the tutorial in a different J session from my testing work >> > to prevent the tutorials from breaking my tests.) >> > >> > Anyways, I'm currently getting an Unrecognized aggregate function >> > error, when trying to use the 'max' aggregate function. This should >> > demonstrate where I'm at: >> > >> > require'jd pacman' >> > load JDP,'tools/csv_load.ijs' >> > F=: jpath '~temp/rosettacode/example/CSV' >> > jdcreatefolder_jd_ CSVFOLDER=: F >> > >> > assert 0<{{)n >> > PATIENTID,LASTNAME >> > 1001,Hopper >> > 4004,Wirth >> > 3003,Kemeny >> > 2002,Gosling >> > 5005,Kurtz >> > }} fwrite F,'patients.csv' >> > >> > assert 0<{{)n >> > PATIENTID,VISIT_DATE,SCORE >> > 2002,2020-09-10,6.8 >> > 1001,2020-09-17,5.5 >> > 4004,2020-09-24,8.4 >> > 2002,2020-10-08, >> > 1001,,6.6 >> > 3003,2020-11-12, >> > 4004,2020-11-05,7.0 >> > 1001,2020-11-19,5.3 >> > }} fwrite F,'visits.csv' >> > >> > csvprepare 'patients';F,'patients.csv' >> > csvprepare 'visits';F,'visits.csv' >> > >> > csvload 'patients';1 >> > csvload 'visits';1 >> > >> > jd'ref patients PATIENTID visits PATIENTID' >> > >> > echo jd ([echo) deb {{)n >> > reads >> > p.PATIENTID, >> > LASTNAME:p.LASTNAME, >> > first v.VISIT_DATE >> > by >> > p.PATIENTID >> > from >> > p:patients, >> > v:p.visits >> > }} -.LF >> > >> > Now, ... one of my thoughts was that maybe this is a type error, >> > indicating that 'max' does not have a definition for the type of data >> > in this column. However, replacing 'max' with 'first' (which should be >> > defined for any type of column) also gives an "Unrecognized aggregate >> > function' error. >> > >> > So... >> > >> > (1) What am I doing wrong here, and >> > >> > (2) What should I have looked at to discover this information? >> > >> > Thanks, >> > >> > -- >> > Raul >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm