如何从不同的表中选择具有相同值的行

时间:2022-11-16 00:29:35

i am new in sql but not good with the round-abouts of sql codes and scripts

我是sql中的新手,但对于sql代码和脚本的回合不太好

im trying to select bill_no from transactions with the same ref_no that is in the ledger (ref_no is the same as bill_no)

我试图从与分类帐中相同的ref_no的交易中选择bill_no(ref_no与bill_no相同)

i tried using the following sql code:

我尝试使用以下sql代码:

    SELECT account_no ,bill_no, bill_date,bill_amount FROM 
    TRANSACTIONS_HISTORY
    WHERE bill_no IN 
    (SELECT ref_no FROM LEDGER
    WHERE ledger_code = '002')

but i always got the error "Arithmetic overflow error converting nvarchar to data type numeric."

但我总是得到错误“将nvarchar转换为数据类型数字的算术溢出错误”。

*sorry for wrong format, this is my first time posting.

*对不起格式错误,这是我第一次发帖。

1 个解决方案

#1


0  

bill_no and ref_no do not have the same data type.

bill_no和ref_no没有相同的数据类型。

You can convert to a different type by using the CAST function. For example:

您可以使用CAST函数转换为其他类型。例如:

SELECT CAST(ref_no AS INT)

#1


0  

bill_no and ref_no do not have the same data type.

bill_no和ref_no没有相同的数据类型。

You can convert to a different type by using the CAST function. For example:

您可以使用CAST函数转换为其他类型。例如:

SELECT CAST(ref_no AS INT)