clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (40598 in the last week).

CREATE TABLE ACCOUNTS (BANK_ID INTEGER, BRANCH_ID INTEGER, ACCOUNT_NUM INTEGER, CURRENCY VARCHAR(255) PRIMARY KEY(BANK_ID, BRANCH_ID, ACCOUNT_NUM)); CREATE TABLE AMOUNTS (ACCOUNT_REC VARCHAR(255) PRIMARY KEY, AMOUNT INTEGER); INSERT INTO ACCOUNTS(BANK_ID, BRANCH_ID, ACCOUNT_NUM, CURRENCY) VALUES(20, 621, 1001, 'ILS'); INSERT INTO ACCOUNTS(BANK_ID, BRANCH_ID, ACCOUNT_NUM, CURRENCY) VALUES(20, 623, 1002, 'USD'); INSERT INTO ACCOUNTS(BANK_ID, BRANCH_ID, ACCOUNT_NUM, CURRENCY) VALUES(20, 90, 1003, 'GBP'); INSERT AMOUNTS(ACCOUNT_REC, AMOUNT) VALUES('60 621 100', 10000); INSERT AMOUNTS(ACCOUNT_REC, AMOUNT) VALUES('20 623 1002', 20000); INSERT AMOUNTS(ACCOUNT_REC, AMOUNT) VALUES('20 90 1003', 30000);
6 rows affected
 hidden batch(es)


SELECT * FROM ACCOUNTS JOIN AMOUNTS ON ( CONCAT(CONVERT(VARCHAR(255), [BANK_ID]), ' ') + CONCAT(CONVERT(VARCHAR(255), [BRANCH_ID]), ' ') + CONVERT(VARCHAR(255), [ACCOUNT_NUM]) ) LIKE ([AMOUNTS].[ACCOUNT_REC] ); SELECT ACCOUNT_REC FROM AMOUNTS
BANK_ID BRANCH_ID ACCOUNT_NUM CURRENCY ACCOUNT_REC AMOUNT
20 623 1002 USD 20 623 1002 20000
20 90 1003 GBP 20 90 1003 30000
ACCOUNT_REC
20 623 1002
20 90 1003
60 621 100
 hidden batch(es)