帮助联合查询 - 如何添加列描述联合结果 [英] help with union query-how to add column the describe the union result

查看:100
本文介绍了帮助联合查询 - 如何添加列描述联合结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





所以我有一个表有三列代表付款时间表的表(例如第一个istallment,第二部分,第三部分)

so i have a table with three columns representing payments schedule (for example first istallment ,second installment,third installment)


每列与其兄弟代表相关联怨恨日期

each column is associated with its brother representing date for the payments



喜欢这个


product --------- first isntallment -------- date ------------- second installment --- --------日期-------------第三期----------日期

product --------- first isntallment--------date-------------second installment-----------date-------------third installment----------date



现在我想做一个sql select命令给我带来这个细节

now i want to do a sql select command that bring to me this details


产品--------------付款方式--------------日期------- --------金额

product--------------payment type--------------date---------------amount



就在那里做这样的事情

is there away to do such thing


在我的情况下我创建了3个额外的列

in my case i created 3 additional column


每次程序加载时我都会更新那些列,这样每列都会得到这个值(第一期,第二期,第三期)

each time the program loads i update those column so each column get this value (first installment,second installment,third installment)


因此,当我想生成数据时,我在select命令中执行联合代码,其中我选择相同的表3次,每次我选择不同的付款和日期,但我将它们命名为除了代表
的一列之外,每个选择命令都是相同的,它们是支付类型

so when i want to produce the data i do the union code in select command where i select the same table 3 times and at each time i select different payment and date but i name them the same in each select command in addition to one of the column representing them to be a payment type



像这样

select conTents,INVOICEDATE,invoice,customs as payment,due as dateS,custype AS TYPES from eta

union select conTents INVOICEDATE 发票 ,[ 2 nDpayment ] as 付款 due2nd as dateS paytype AS TYPES from eta

union select conTents,INVOICEDATE,invoice,[2nDpayment] as payment,due2nd as dateS,paytype AS TYPES from eta

union select conTents INVOICEDATE 发票 advance as 付款 DUE AS DATES advtype AS TYPES from eta

union select conTents,INVOICEDATE,invoice,advance as payment,DUE AS DATES,advtype AS TYPES from eta




有更好的方法可以做到这一点,尤其是列支付类型,而不是为三次付款创建自己的列

is there better way to do this especially for the column payment type instead of creating its own column for the three payments


在我的表中看起来像这样

to look something like this in my table



这是最终结果

this is the net result


推荐答案


MedicalDoctorProgrammer,

你的描述有点令人困惑。

your description is little bit confusing.

首先你说你的表中有3列。

first you said you had 3 columns in table.

然后你说每列都有日期。所以现在共有6列。

then you said each column have date also. so now there is a total 6 columns.

然后当你选择查询中的数据时,你提到的列在查询中与上面的描述完全不同。

then when you select the data in query, the columns you mentioned in the query are totally different then your description above.

因此我无法正确理解您的表格实际外观以及您想要的输出。

so I am not able to understand properly that how your table actually looks like and what output you want.

可以再次尝试向我们展示您的表格和数据的外观以及您想要的确切输出。您最好发布它的图片。这样我们就可以看到它并尝试正确理解它。

can please again try to show us how your table and data looks and what exact output you want. it is better you post the picture of it. so that we can see it and try to understand it properly.

如果p您可以尝试使用虚拟数据发布数据库。

if possible for you then you can also try post your database with dummy data in it.

告诉我们上面提到的详细信息,我们会尽力为您提供进一步的建议。

let us know about the details I asked above and we will try to provide you further suggestions.

问候

Deepak


这篇关于帮助联合查询 - 如何添加列描述联合结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆