Jump to content

Add column to select statement (ie value from another table)


Michelle

Recommended Posts

Hi there,

Could anyone please help me to combine the below SQL statements such that the result is a 4 column table as shown in my screenshot? 

/* entire table here */
SELECT AutoNumber, DDAte, Amount
FROM LedgerTransactions LT 
WHERE DDATE >= DATEFROMPARTS(2019,01,01) 
AND LT.AccNumber IN 
 (select distinct AccNumber FROM LedgerMaster) 
ORDER BY ddate DESC

/* add CoName to above table as 4th column,
   same value for every row */
select CoName from LedgerParameters

Thank you in advance,
Michelle

screenshot.png

Edited by Michelle
trying to notify myself if reply, cant find it
Link to comment
Share on other sites

Not to worry thank you, I found the answer:

 

SELECT AutoNumber,DDAte,Amount*(-1) as Amount, (select CoName from LedgerParameters) as Company 
FROM LedgerTransactions LT 
WHERE DDATE >= DATEFROMPARTS(2019,01,01) 
AND LT.AccNumber IN 
 (select distinct AccNumber FROM LedgerMaster) 
ORDER BY ddate DESC

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...