Skip to content

Tag: sql

Oracle SQL query to get comma-separated string in single query

I have a data which is represented as below: I have a query as follows which has to be tweaked to get parent and child names respectively My output should look as follows: I basically want to split the lk.name based on seperator (,) and 1st string before seperator is parentName and 2nd string after seperator …

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 …