如何“在不同的行中列"?放置在“单行中的不同列"中. [英] How can "column in different row" be placed "different column in single row"

查看:80
本文介绍了如何“在不同的行中列"?放置在“单行中的不同列"中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要按两行分组,并且同一列的不同两行的值要放在同一行的不同列中.下面是我的表

I want to group by two row and value of different two row of same column want to placed in different columns in a single row.below is my table

例如,我不希望1&单行中有2行.单行中将有ref_no(两行相同),由(VOUCHER_BY为Cr的LEDGERNAME)到(VOUCHER_BY为Cr的LEDGERNAME),AMOUNT(两行相同)或类似这 -

For example, I want no 1 & 2 row in a single row.In a single row,there will be ref_no(same in both row),by(LEDGERNAME whose VOUCHER_BY is Dr),to(LEDGERNAME whose VOUCHER_BY is Cr),AMOUNT(same in both row) or like this--

我使用了oracle数据库.该怎么办?

I used oracle database.How can i do this?

推荐答案

简单.自行加入:

select d.ref_no,
    d.ledgername by,
    c.ledgername to,
    d.amount
from my_ledger_table d
inner join my_ledger_table c on d.ref_no = c.ref_no
    and d.voucher_by = 'Dr'
    and c.voucher_by = 'Cr'
    and d.amount = c.amount;

这篇关于如何“在不同的行中列"?放置在“单行中的不同列"中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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