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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting a selected column in select field

Status
Not open for further replies.

NewbieScoobie

Technical User
Feb 8, 2009
8
NZ
Hi, i'm quite new to T-Sql and was wondering if i could do the following:

select

k.name,
(select Hours from otherTable where selected = 'Y') as importedfield,
(case when k.name = 'timmy' then importedfield else 'no' end)

from

origtable k

order by k.name

essentially i want to use the value of 'imported field' for the value only if the current row in k.name = 'timmy'

is there any way i can do this?

thanks
 
how many rows in otherTable have selected = 'Y' ?

if it's more than one, then that subquery in the SELECT clause won't work

what are you trying to do? how are the tables related?

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top