September 15, 2011 at 11:18 pm
the below query doctorid columns having data like ALL and doctorId's (100,101,121 ...)..IF doctorid ALL need to display doctorname column 'ALL' and doctorid having number need to display doctorname column name of that doctorid ...i wrote case like this but its not showing the result please some one help me..
SELECT tr.practice_id,pr.practice_name,tr.user_id,CONCAT(u.first_name,' ' ,u.last_name) AS 'User_Name',
tr.doctor_id, CASE WHEN tr.doctor_id ='ALL' THEN 'ALL' ELSE CONCAT(dr.first_name,' ' ,dr.middle_name,' ',dr.last_name)
END AS 'Doctor_Name' FROM tf_random_sampling_user_preferences tr
INNER JOIN tf_practice_details pr ON pr.practice_id=tr.practice_id
INNER JOIN tf_user_details u ON u.user_id=tr.user_id
INNER JOIN tf_doctor_details dr ON dr.doctor_id=tr.doctor_id
WHERE tr.user_id IN (3235,3161,3250,3255,3101,54,2969)
September 15, 2011 at 11:20 pm
What is the desired output supposed to look like? Please provide a sample.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
September 15, 2011 at 11:25 pm
This:
SELECT tr.practice_id,pr.practice_name
,tr.user_id,CONCAT(u.first_name,' ' ,u.last_name) AS 'User_Name'
,tr.doctor_id
,CASE WHEN tr.doctor_id ='ALL' THEN 'ALL'
ELSE dr.first_name + ' ' +dr.middle_name+' '+dr.last_name
END AS 'Doctor_Name'
FROM tf_random_sampling_user_preferences tr
INNER JOIN tf_practice_details pr
ON pr.practice_id=tr.practice_id
INNER JOIN tf_user_details u
ON u.user_id=tr.user_id
INNER JOIN tf_doctor_details dr
ON dr.doctor_id=tr.doctor_id
WHERE tr.user_id IN (3235,3161,3250,3255,3101,54,2969)
September 16, 2011 at 2:11 am
...CONCAT...
Is this Oracle SQL?
-- Gianluca Sartori
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply