SQL:插入别名a以使列名具有2行

时间:2016-12-15 10:54:19

标签: sql openoffice.org

我在OpenOffice Base中工作,类似于Access。 我有一个表(成本)和以下列(每个月有2个值(付费和待定):

  • 提供商

  • Januarypay

  • Januarypend

  • Februarypay

  • Februarypend

  • Marchpay

  • Marchpend

  • Aprilpay

  • Aprilpend

  • Maypay

  • Maypend

  • Junepay

  • Junepend

  • Julypay

  • Julypend

  • Augustpay

  • Augustpend

  • Septemberpay

  • Septemberpend

  • Octoberpay

  • Octoberpend

  • Novemberpay

  • Novemberpend

  • Decemberpay

  • Decemberpend

我正在尝试这样的事情

Select "provider",**"NEEDHELPHERE"**,(select (Januarypay + Januarypend + Februarypay + Februarypend + Marchpay + Marchpend + Aprilpay + Aprilpend + Maypay + Maypend + Junepay + Junepend + Julypay + Julypend + Augustpay + Augustpend + Septemberpay + Septemberpend + Octoberpay + Octoberpend + Novemberpay + Novemberpend + Decemberpay + Decemberpend) as TotalYear from "Costs")

替换“NEEDHELPHERE”以获取以下代码(我把它放了,否则这会太长):

Januarypay as "January" || char(10)|| char(13) || "Paid",Januarypend as "January" || char(10)|| char(13) || "Pending",Februarypay as "February" || char(10)|| char(13) || "Paid",Februarypend as "February" || char(10)|| char(13) || "Pending",Marchpay as "March" || char(10)|| char(13) || "Paid",MarchpendMarchpay as "March" || char(10)|| char(13) || "Pending",Aprilpay as "April" || char(10)|| char(13) || "Paid",AprilpendAprilpay as "April" || char(10)|| char(13) || "Pending",Maypay as "May" || char(10)|| char(13) || "Paid",Maypend as "May" || char(10)|| char(13) || "Pending",Junepay as "June" || char(10)|| char(13) || "Paid",Junepend as "June" || char(10)|| char(13) || "Pending",Julypay as "July" || char(10)|| char(13) || "Paid",Julypend as "July" || char(10)|| char(13) || "Pending",Augustpay as "August" || char(10)|| char(13) || "Paid",Augustpend as "August" || char(10)|| char(13) || "Pending",Septemberpay as "September" || char(10)|| char(13) || "Paid",Septemberpend as "September" || char(10)|| char(13) || "Pending",Octoberpay as "October" || char(10)|| char(13) || "Paid",Octoberpend as "October" || char(10)|| char(13) || "Pending",Novemberpay as "November" || char(10)|| char(13) || "Paid",Novemberpend as "November" || char(10)|| char(13) || "Pending",Decemberpay as "December" || char(10)|| char(13) || "Paid",Decemberpend as "December" || char(10)|| char(13) || "Pending"

查询的结果应该是这样的: sql result example

表格信息

table info

表格示例数据 sample data

0 个答案:

没有答案