SQL replace question

anichols

Board Regular
Joined
Mar 11, 2021
Messages
87
Office Version
  1. 365
Platform
  1. Windows
hello all,

I have this functioning SQL code:
SQL:
SELECT LOANMAST.BANK, LOANMAST.BRANCH,
       LOANMAST.LOAN_NBR, USERF.USER13A, LOANMAST.POSTDATE, 
       LOANMAST.LOAN_AMT, LOANMAST.SHORT_NAME
--USER13A must say "D" in all rows

FROM LOANMAST LOANMAST
      LEFT OUTER JOIN BORRLIST BORRLIST ON 
     (BORRLIST.BANK = LOANMAST.BANK)
      AND (BORRLIST.BRANCH = LOANMAST.BRANCH)
      AND (BORRLIST.LOAN_NBR = LOANMAST.LOAN_NBR)
      LEFT OUTER JOIN BORROWER BORROWER ON 
     (BORROWER.XUNIQUE = BORRLIST.BORROWER)
      LEFT OUTER JOIN PARTLOAN PARTLOAN ON 
     (PARTLOAN.BANK = LOANMAST.BANK)
      AND (PARTLOAN.BRANCH = LOANMAST.BRANCH)
      AND (PARTLOAN.LOAN_NBR = LOANMAST.LOAN_NBR)
      LEFT OUTER JOIN USERF USERF ON 
     (USERF.BANK = BORRLIST.BANK)
      AND (USERF.BRANCH = BORRLIST.BRANCH)
      AND (USERF.LOAN_NBR = BORRLIST.LOAN_NBR)
      LEFT OUTER JOIN DELINQ DELINQ ON 
     (DELINQ.BANK = USERF.BANK)
      AND (DELINQ.BRANCH = USERF.BRANCH)
      AND (DELINQ.LOAN_NBR = USERF.LOAN_NBR)
      LEFT OUTER JOIN BROKER BROKER ON 
     (BROKER.XUNIQUE = BORRLIST.XUNIQUE)
WHERE ( BORRLIST.XTYPE = 1 )
       AND ( LOANMAST.BANK = 136 )
       AND ( LOANMAST.BPRIN_BAL = 0)
       AND ( LOANMAST.POSTDATE < curDate() )
ORDER BY LOANMAST.POSTDATE DESC

Column #4, I am just trying to replace all the values in the column with "D". I'm struggling to do it correctly, so any help would be greatly appreciated.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Select queries cannot physically update the underlying records (that would be am Update Query).
However, if you just want to return the letter "D" for all records, then simply do a calculated field, returning the hard-coded value of "D", i.e.
Rich (BB code):
SELECT LOANMAST.BANK, LOANMAST.BRANCH,
       LOANMAST.LOAN_NBR, 'D' as [USER13A], LOANMAST.POSTDATE, 
       LOANMAST.LOAN_AMT, LOANMAST.SHORT_NAME
...
 
Upvote 0
Solution
Brilliant! I've learned something new today. Thank you very much!
<Insert emoji of me tipping my hat to you>
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,224,915
Messages
6,181,725
Members
453,064
Latest member
robatthe2A

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top