单行查询返回多个行 [英] single row query Return More than One Row

查看:136
本文介绍了单行查询返回多个行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友...这是我的查询

Hello friends...here Is My Query

select TRAN_AMOUNT AS CLOSING_BAL 
  From LOANTRAN 
 WHERE TRAN_DATE IN ( select AC_CLOSEDT from LNMASTER 
                       where AC_NO BETWEEN 100 AND 200 ) 
   AND ROWID IN ( SELECT MAX(ROWID) FROM LOANTRAN 
                   WHERE TRAN_ACNO BETWEEN 100 AND 200)



实际的问题是,我想创建一个带有某些帐户编号及其期末余额的水晶报表.

这是LOANTRAN Tbl的演示...



Actually problem is, I want to create a crystal report with some account no and their closing balance.

Here is Demo Of LOANTRAN Tbl...

TRAN_ACNO    TRAN_DATE    TRAN_AMOUNT
1             2/2/2001       2000
2             2/2/2001       1500
3             2/2/2001       3000
2             2/2/2001       3700
3             2/2/2001       4500



我想选择一个垂直TRAN_ACNO的最后一个横断..在上面的示例中,一天中有两次Ac.No 2条目..这意味着金额3700是2号帐户的结余余额...(结算余额意思是该天任何帐户的最后一笔付款..Ac.No 3的期末余额为4500)我想从LOANTRAN的no.100至200之间的帐户表中选择该期末余额...

请帮助我.....
库马尔
Oracle开发人员
[DELETED] @ yahoo.co.in

[edit]除非您真的喜欢垃圾邮件,否则请不要在任何论坛中发布您的电子邮件地址!如果有人回复您,您将收到一封电子邮件,通知您-OriginalGriff [/edit]
[edit2]只需清理sql,以便更直观地解析-Marcus [/edit2]



I want to select last transection of One Perticular TRAN_ACNO .. in Above Example there are two times entry of Ac.No 2 in a single day..That means The Amount 3700 Is a closing Balence Of Acount No 2...(Closing Balance Means Last transection of any Account on that Single Day.. Ac.No 3 has Closing Balance 4500) i want to select such Closing Balance from LOANTRAN table of Account no Between 100 AND 200...

Please help Me.....
Kumar
Oracle Developer
[DELETED]@yahoo.co.in

[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know - OriginalGriff[/edit]
[edit2]Just cleaned up the sql so that it''s easier to parse visually - Marcus[/edit2]

推荐答案

,只要您拥有 在SQL中的... ... 100和200之间的子句... 子句中,您可能会返回多行.您将需要找到一种方法来将这些块缩小为单行返回,以使整个查询返回一行.除非您在LNMASTER表上提供更多信息,否则我不会告诉您应该是什么样.
As long as you have the WHERE ... BETWEEN 100 AND 200 clauses in your sql, you are potentially going to get multiple rows returned. You''ll need to find a way to narrow these blocks down to single row returns in order to get the entire query to return one row. I can''t tell you what that should look like unless you provide a bit more info on the LNMASTER table.


这篇关于单行查询返回多个行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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