Skip to content

Sql where Condition execution not working

I have the following query logic Show comments which is not deleted Show comments which is deleted after created, within a timespan of 30 days before today(Today – Createddate <= 30) Below is the logic which I wrote, but I don’t think it is working correct. Answer

How add select in list without join

I don’t need to join in a whole table, but just want a value from the table returned in my select list (but other tables are joined for other items). It’s giving me an error…incorrect syntax near select I’m having trouble searching online for this. Answer Assuming the scalar subquery r…

SQL: Return Aggregated Results based on some conditions

I need help with making a conclusion in SQL Server based on some column’s values, like status aggregation sort of. As an example, below is a table containing server tasks and their status. If I want to return the aggregated status of each server here are the rules: if all the server tasks are at status …

Return false if no rows for select

I have next query: It works fine, if we have some records in new_date table, but if it is empty for some user, query just returns empty string. How I can return false, if there are no records also? Answer You could just selects an EXISTS expression here: This would always return just a single record, containi…