echo> "%SQL3%" .read "%SQL%"
echo>>"%SQL3%" .read "%SQL_URDT%"
echo>>"%SQL3%" .read "%SQL_UMSI%"
echo>>"%SQL3%" .read "%SQL_SHSZ%"
::echo>>"%SQL3%" .eqp full
echo>>"%SQL3%" .headers on
echo>>"%SQL3%" .mode html
echo>>"%SQL3%" .nullvalue NULL
echo>>"%SQL3%" .once stdout
echo>>"%SQL3%" .print "
"
echo>>"%SQL3%" select ’Šo”͈Í, ‘fÞ–¼
echo>>"%SQL3%" , sum(‘fÞ”—Ê*¤•i‘”) as ‘fÞ”—Ê‘Œv
echo>>"%SQL3%" , group_concat('('^|^|¤•i”Ô†^|^|') '^|^|¤•i–¼^|^|coalesce(' ('^|^|‘fÞ”—Ê^|^|'~'^|^|¤•i‘”^|^|'='^|^|(‘fÞ”—Ê*¤•i‘”)^|^|')',' (~'^|^|¤•i‘”^|^|')',''), char(10)) as ‘fÞ—v‹¤•i“à–ó
echo>>"%SQL3%" from (
echo>>"%SQL3%" select ’Šo”͈Í, ¤•i”Ô†, case when 0 ^< length(¤•i–¼) then ¤•i–¼ else ¤•i”Ô†^|^|'”Ԃ̤•i' end as ¤•i–¼
echo>>"%SQL3%" , sum(¤•iŒÂ”) AS ¤•i‘”
echo>>"%SQL3%" , ‘fÞ–¼, ‘fÞ”—Ê, ‘fÞ–¼‡˜
echo>>"%SQL3%" from (select *
echo>>"%SQL3%" , '['^|^|%BEGINDATE%^|^|','^|^|%LASTDATE%^|^|']' as ’Šo”͈Í
echo>>"%SQL3%" from URDT•\
echo>>"%SQL3%" where –ß“ü’S“– = 0 and
echo>>"%SQL3%" —\–ñ“úŽž between %BEGINDATE% and date(%LASTDATE%,'+1 day')
echo>>"%SQL3%" -- The range of "between A and B" is inclusive but
echo>>"%SQL3%" -- if X is a datetime and B is the date part of X,
echo>>"%SQL3%" -- X always exceeds B even when X is 'B 00:00' andor
echo>>"%SQL3%" -- even X is 'B ' (as of SQLite3.20.0).
echo>>"%SQL3%" ) natural join UMSI•\
echo>>"%SQL3%" natural left join ¤•i‘fÞ•\
echo>>"%SQL3%" natural left join ¤•i”Ô†–¼‘O•\
echo>>"%SQL3%" natural left join ‘fÞ–¼‡˜•\
echo>>"%SQL3%" group by ‘fÞ–¼, ¤•i”Ô†
echo>>"%SQL3%" )
echo>>"%SQL3%" group by ‘fÞ–¼
echo>>"%SQL3%" order by ‘fÞ–¼‡˜
echo>>"%SQL3%" ;
echo>>"%SQL3%" .print "
"