How do you count "Count"?
Why is "Northwest" 1 instead of 2 for 2021?


For now so:

select v.Branchnvl(sum(%FOREACH(v.Branch)),0) "Count" from 
  (
  select 'Northwest' Branch,$listbuild('Northern','Western'Branches union
  select 'Oriental',$listbuild('Eastern'union
  select 'Southern',$listbuild('Southern')
  ) v
left join
  (select replace(%exact(Branch),' branch',''Branch,count(%FOREACH(Branch)) from yourtable where year("Date")=2021 group by Branchm
on m.Branch %inlist v.Branches
group by v.Branch

You are implicitly using %Library.SqlQuery:Func() method, in which, as @Robert Cemper rightly pointed out, $get() is used.

You can do it differently:

Query GetInfo(pObject AS Kurro.MyClassAs %SQLQuery(CONTAINID 1ROWSPEC "IdList:%String,IdProcess:%String,Duration:%String") [ SqlProc ]
{
    SELECT IdListIdProcessDuration
    FROM Kurro.MyClass
    WHERE KeyProcess :pObject.KeyProcess
    AND CodeSpecialist :pObject.CodeSpecialist
    AND CodeProvider :pObject.CodeProvider
    AND CodeCenter :pObject.CodeCenter
    AND "Date" :pObject.Date
}


set obj=##class(Kurro.MyClass).%New()
set obj.KeyProcess="1033004-1#"
set obj.CodeSpecialist "surgery"
set obj.CodeProvider "PR002"
set obj.CodeCenter "CENTER-01"
set obj.Date $ZDATETIME($ZDATETIMEH("2021-04-30 15:45:00",3,1),3,1)

set st=##class(%SQL.Statement).%New()
set sc=st.%PrepareClassQuery("Kurro.MyClass","GetInfo")
  if $$$ISERR(sc{write "%PrepareClassQuery failed:" do $System.Status.DisplayError(scquit}
set result=st.%Execute(obj)
do result.%Display()

I don't quite understand what you want to get.

If in the forehead, then so:

Select v.valueIdm.name 
 From (Select valueId Union Select Union Select Union Select Union Select 5) v
     left Join otherTable m
        on m.id v.valueId

But you can achieve the same thing more easily through IN or %INLIST.

If you use Studio to edit/compile *.csp files, check the following parameters:

  • Enable service status check (Recommended) (yes)
  • Studio is active application (2–60 sec) (5)
  • Studio is background application (30–600 sec) (60)
  • Automatically reload document when it is modified on the server and it has not been edited in Studio (yes)

And also see Caché Launcher (Cube) settings : Web Server IP Address / CSP Server Instance


I tried to simply edit the file in Studio (csp/samples/redirect.csp) and with an external editor FAR Manager ([CACHEROOT]\CSP\samples\redirect.csp)
For simplicity, I changed the comment in the header. I tested everything both locally and remotely.

So, I change it in Studio - the changes are immediately visible in FAR, I change it in FAR - the changes are immediately visible in Studio.
Or in another way: I change it locally - the changes are immediately visible on the remote machine, I change it on the remote machine - the changes are immediately visible locally.

In other words, there is no and cannot be any desynchronization, since the work is always done with the same file on the server, see Saving a CSP File.