Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR 8.5: Subselect field doesn't appear in field list 1

Status
Not open for further replies.

azoe

Technical User
Feb 21, 2005
175
US
I have created a stored procedure from the query below to use in my report.

The problem is that the only field that shows up in the "Insert Fields" list is td.adj_amt. I also need to display rcm.desc_40 (in the subselect).

Why isn't it there and/or how can I get it there?

Thank you -


SELECT

(Select Top 1 rcm.desc_40
From reason_code_links rcl
left outer join reason_code_mstr rcm on rcl.reason_code_id = rcm.reason_code_id
Where rcl.trans_id = t.trans_id),
td.adj_amt

FROM
trans_detail td
inner join transactions t on td.trans_id = t.trans_id

where
t.closing_date between '20050302' and '20050401'
and t.type = 'A'
 
You need to alias the column you're returning from the subquery:

SELECT desc_40 =
(Select Top 1 rcm.desc_40
From reason_code_links rcl
left outer join reason_code_mstr rcm on rcl.reason_code_id = rcm.reason_code_id
Where rcl.trans_id = t.trans_id), td.adj_amt
etc......

-dave
 
Thanks that was it!

Have a great weekend. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top