Modify query to enter a data to a table. SQL server

0

I have the following query:

 SELECT A.CardName FROM OCRD A 
 INNER JOIN OSLP B ON A.SlpCode = B.SlpCode WHERE B.SlpCode = 1 AND LicTradNum = 'XAXX010101000'

It generates a list of customers corresponding to the seller with ID (SlpCode is the column to identify the sellers) number 1.

Necessity: Assign each vendor one more item called "Sales counter" in the CardName column. This has to change the code, but I do not know in what way I can assign ALL sellers that element.

    
asked by Elizabeth 05.07.2018 в 15:13
source

1 answer

1

You just have to add the string with the information that you want to assign to each record

SELECT 'Ventas Mostrador', A.CardName FROM OCRD A 
INNER JOIN OSLP B ON A.SlpCode = B.SlpCode WHERE B.SlpCode = 1 AND LicTradNum = 'XAXX010101000'

If you want to add an alias to that column, (since by default it will be created with the name No column name ), you add a AS

SELECT 'Ventas Mostrador' AS NombreColumna, A.CardName FROM OCRD A 
INNER JOIN OSLP B ON A.SlpCode = B.SlpCode WHERE B.SlpCode = 1 AND LicTradNum = 'XAXX010101000'
    
answered by 05.07.2018 / 16:13
source