Link to home
Start Free TrialLog in
Avatar of gtrapp
gtrapp

asked on

Help with SQL

I have a program that generated SQL for a report. I am not sure what "=" is for in the SELECT section of the query.  For example, the  "ctx_id = v_ctx_basic_info.ctx_id". Not sure what this is doing.   The query does do an inner join on two views by using the ctx_id, but what does this statement do "ctx_id = v_ctx_basic_info.ctx_id"?  Why do I need it?


SELECT DISTINCT
	ctx_id = v_ctx_basic_info.ctx_id,  
	contract_type_Description = v_ctx_basic_info.contract_type_Description,  
	custom_1 = v_ctx_basic_info.custom_1,  
	Company_Name = v_ctx_basic_info.Company_Name,  
	expriation_date = v_ctx_basic_info.expriation_date,  
	product_description = v_ctx_basic_info.product_description
 FROM 
v_ctx_basic_info INNER JOIN v_ctx_custom on (v_ctx_basic_info.ctx_id=v_ctx_custom.ctx_id)

Open in new window

Avatar of Drutch
Drutch

"ctx_id = v_ctx_basic_info.ctx_id" is simply  renaming the field ctx_id from table v_ctx_basic_info to ctx_id.
SELECT Superman = v_ctx_basic_info.ctx_id FROM v_ctx_basic_info
would result in:
Superman
|----------|--
     1
      2
ASKER CERTIFIED SOLUTION
Avatar of Drutch
Drutch

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial