One common way to solve this problem is to use a wrapper function called a document here, try the following:
sqlite3 /Users/user/Documents/Test/dbName.dba <<EOS
insert into myTable (Date, Details, Category, Average)
values(datetime('now','localtime'), '$1', '$2', '$3');
select "Category1 total = " sum(Average) from (
select * from myTable where Category = 'category1'
);
select "Category2 total = " sum(Average) from (
select * from myTable where Category = 'category2'
);
EOS
, EOS , ( , EndOfScript), .
sqlite3, - , , . , , "1 " , sqlite3 , "$ 1" .. , "CategoryN total = ".
, SQL- sql, , . , , , , , DML .
, .
( , , , , OS/Linux Ver , ).