【发布时间】:2014-09-10 08:57:53
【问题描述】:
如何在 unix 中使用 SQL 查询的输出填充 Csv 文件
我所做的是
#! /bin/ksh
echo ",A,B,C\n D\n E">abc.csv
sqlplus -s scott/tiger@host<< EOF >> abc.csv
SET COLSEP ","
SET HEADING OFF
select count(a1) from tab1 where condition group by clause;
select count(b1) from tab1 where condition group by clause;
exit
EOF
uuencode abc.csv abc.csv | mailx -s "Output" email@id.com
输出
a b c
d
e
result q1
{a1
b1
c1}
result q2
{
A
B
C
}
期望的输出
a b c
d a1 b1 c1
e A B C
我如何获得所需的输出 如果我必须在“c”(列标题)之后添加一个“总计”列,需要做什么
【问题讨论】:
-
sqlplus是甲骨文。你确定你使用 mysql 因为你的问题被标记了? -
它的#oracle 是我的错误