Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
LinkedIn
Online Members
Devaraj T N
Phagu Mahato
Priya jain
srirama
More...
Join our online
Google+ community
for Bloggers, Content Writers and Webmasters
Forums
»
.NET
»
SQL Server
»
Check whether no record for join condion
Posted Date:
20 Mar 2009
Posted By::
Babu Kumarasamy
Member Level:
Gold
Member Rank:
1161
Points
: 1
Responses:
1
Hi,
My requirement is that if there is no record in Log Table for the Batch Table Join Condition Log.ID = Batch.ID AND Log.LogDT = Batch.BatchDT, Then we have to get the Batch.BatchValue when
COUNT(Log.totalHrs) = 0
We have to check whether this is null or empty i.e. there is no record for the condition in Log table. This is thing I need.
else if there is record for Id and the BatchDT we get the min of Log.LogValue
totalHrs DataType is Time
SELECT Batch.BatchHrs,
Hrs =
CASE
WHEN COUNT(Log.totalHrs) = 0
OR Log.TotalHrs = '00:00:00.0000000'
THEN Batch.BatchValue
ELSE MIN(Log.LogValue)
END
FROM Batch
LEFT JOIN Log
ON Log.ID = Batch.ID
AND Log.LogDT = Batch.BatchDT
WHERE Batch.ID = '01'
AND Batch.BatchDT = '3/20/2009'
GROUP BY Batch.BatchHr
Thanks,
Babu Kumarasamy
Tweet
Responses
#370773 Author:
Abhishek Arya
Member Level:
Gold
Member Rank:
21
Date: 26/Apr/2009 Rating:
Points
: 2
you can use if condtion too for checking the value of count. or User define function which will me more fater.
Post Reply
This thread is locked for new responses. Please post your comments and questions as a
separate thread
.
If required, refer to the URL of this page in your
new post
.
Tweet
Next :
Connection pooling
Previous :
Doubt in stored procedure
Return to Discussion Forum
Post New Message
Category:
Related Messages
Exporting SQL Server Table to Excel Using DTS
Function is not working
trigger problem.
DATE SEARCH IN ASPX PAGE
Any body tell good pl sql book reference URL and FAQ
Follow us on Twitter:
https://twitter.com/dotnetspider
Active Members
Today
srirama
(22)
Phagu Mahato
(11)
baskar
(7)
Last 7 Days
baskar
(300)
Asheej T K
(203)
srirama
(185)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds
About Us
Contact Us
Copyright
Privacy Policy
Terms Of Use
Revenue Sharing sites
Advertise
Talk to
Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.