Solved

How to replace non D values in column with blank

Posted on 2013-05-15
6
273 Views
Last Modified: 2013-05-16
I have this query for joining.
There is field ems, it has numerical values, E or D.
Now how to modify this query where in
if for any record ems is number i,e numeric value or 'E'  values it should occur as blank.
and for ems ='D' it should be shown as 'D'

select a1.*,b.photo,b.subjectcode,b.subjectname,b.ems  from (select institute,cb,semester,UID,sname,
smobile ,isnull(fmobile,'') as 'fmobile',isnull(fname,'')  as fname,isnull(mname,'') as 'mname',
centreno as 'Centreno',centre as 'Centre' from custudents  a where cb='MBA' and eflag=1
group by institute,cb,semester,UID,sname,smobile ,isnull(fmobile,''),
isnull(fname,'')  ,isnull(mname,'') ,
centreno ,centre)
as a1,mstmassstudents b
where a1.uid=b.uid and a1.cb='MBA'
order by a1.uid,b.subjectcode
0
Comment
Question by:searchsanjaysharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Accepted Solution

by:
santoshmotwani earned 333 total points
ID: 39170432
select a1.*,b.photo,b.subjectcode,b.subjectname,
case b.ems
when 'D' then 'D'
else ' '
  from (select institute,cb,semester,UID,sname,
smobile ,isnull(fmobile,'') as 'fmobile',isnull(fname,'')  as fname,isnull(mname,'') as 'mname',
centreno as 'Centreno',centre as 'Centre' from custudents  a where cb='MBA' and eflag=1
group by institute,cb,semester,UID,sname,smobile ,isnull(fmobile,''),
isnull(fname,'')  ,isnull(mname,'') ,
centreno ,centre)
as a1,mstmassstudents b
where a1.uid=b.uid and a1.cb='MBA'
order by a1.uid,b.subjectcode
0
 
LVL 25

Assisted Solution

by:chaau
chaau earned 167 total points
ID: 39170433
Replace d.ems in your query with this:

CASE WHEN d.ems = 'D' THEN 'D' ELSE '' END

Open in new window

0
 
LVL 16

Assisted Solution

by:santoshmotwani
santoshmotwani earned 333 total points
ID: 39170438
select a1.*,b.photo,b.subjectcode,b.subjectname,
case b.ems
when 'D' then 'D'
else ' '
end b.ems
  from (select institute,cb,semester,UID,sname,
smobile ,isnull(fmobile,'') as 'fmobile',isnull(fname,'')  as fname,isnull(mname,'') as 'mname',
centreno as 'Centreno',centre as 'Centre' from custudents  a where cb='MBA' and eflag=1
group by institute,cb,semester,UID,sname,smobile ,isnull(fmobile,''),
isnull(fname,'')  ,isnull(mname,'') ,
centreno ,centre)
as a1,mstmassstudents b
where a1.uid=b.uid and a1.cb='MBA' 
order by a1.uid,b.subjectcode

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:PortletPaul
ID: 39170467
there's just an END missing in your original query in that case expression as indicated here
0
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 39170480
yep !! i fixed it and did a repost

Ta
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39170782
tx
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question