ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display Column value based on condition in Join query using Case statement in SQL Server<p>Hi <a class="username" rel="nadeem1218">nadeem1218</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">DECLARE @TestTable AS TABLE(ID INT, Name VARCHAR(20),CheckIn DATETIME,CheckOut DATETIME) INSERT INTO @TestTable VALUES(1,&#39;John Hammod&#39;,&#39;2019/06/12&#39;,&#39;2019/06/13&#39;) INSERT INTO @TestTable VALUES(2,&#39;Mudassar Khan&#39;,&#39;2019/06/13&#39;,&#39;2019/06/14&#39;) INSERT INTO @TestTable VALUES(3,&#39;Suzanne Mathews&#39;,&#39;2019/06/14&#39;,&#39;2019/06/15&#39;) INSERT INTO @TestTable VALUES(4,&#39;Robert Schidner&#39;,NULL,NULL) SELECT ID,Name,CheckIn,CheckOut,CASE WHEN CheckIn IS NULL AND CheckOut IS NULL THEN &#39;ABSENT&#39; ELSE &#39;PRESENT&#39; END &#39;IsAbsent&#39; FROM @TestTable</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/187974/Display-Column-value-based-on-condition-in-Join-query-using-Case-statement-in-SQL-Server/https://www.aspforums.net:443/Threads/187974/Display-Column-value-based-on-condition-in-Join-query-using-Case-statement-in-SQL-Server/Mon, 17 Jun 2019 02:59:10 GMTDisplay Column value based on condition in Join query using Case statement in SQL Server<p>Hi Pandeyism,</p> <p>Thanks for the answer. But there is one issue if you see my query, it has multiple sub-queires and joins. Im not sure this approach will work.</p> <p>Regards,</p> <p>Nadeem</p>https://www.aspforums.net:443/Threads/187974/Display-Column-value-based-on-condition-in-Join-query-using-Case-statement-in-SQL-Server/https://www.aspforums.net:443/Threads/187974/Display-Column-value-based-on-condition-in-Join-query-using-Case-statement-in-SQL-Server/Mon, 17 Jun 2019 03:21:33 GMTDisplay Column value based on condition in Join query using Case statement in SQL Server<p>Hi <a class="username" rel="nadeem1218"> nadeem1218,</a></p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p>For this sample I have used of NorthWind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-the-Northwind-and-Pubs-Sample-Databases-in-SQL-Server-Express.aspx" target="_blank"> Download Northwind Database</a></p> <p>Refer below sample query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">SELECT c.CustomerID, c.CompanyName,c.Country, CASE WHEN c.Region IS NULL THEN &#39;Absent&#39; ELSE &#39;PRESENT&#39; END &#39;IsAbsent&#39; FROM Orders o INNER JOIN Customers c ON c.CustomerID = o.CustomerID</pre>https://www.aspforums.net:443/Threads/187974/Display-Column-value-based-on-condition-in-Join-query-using-Case-statement-in-SQL-Server/https://www.aspforums.net:443/Threads/187974/Display-Column-value-based-on-condition-in-Join-query-using-Case-statement-in-SQL-Server/Mon, 17 Jun 2019 03:42:43 GMT