Solved

Help with Sql query(Select)

Posted on 2009-07-11
2
171 Views
Last Modified: 2012-05-07
Hi Experts,
I have written following query,
select v.village_name,s.new_survey_no from tbSurvey s inner join tbLACase lc on s.lac_no = lc.lac_no
inner join tbVillage v on v.village_id = s.village_id where lc.lac_no = '1/A-65/1998-99'

Now there is a column 'possession_date' in tbSurvey.In the above query,I want to show possession_status.
If possession_date is entered in the tbSurvey for that new_survey_no,I want to show 'Yes' else 'No'

How to do this?
0
Comment
Question by:johny_bravo1
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24833519
simple case expression:
select v.village_name,s.new_survey_no 
, CASE WHEN s.possession_date IS NULL THEN 'No' ELSE 'Yes' END as possession_status
from tbSurvey s inner join tbLACase lc on s.lac_no = lc.lac_no 
inner join tbVillage v on v.village_id = s.village_id where lc.lac_no = '1/A-65/1998-99'

Open in new window

0
 
LVL 8

Author Closing Comment

by:johny_bravo1
ID: 31602536
Thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now