Skip to content

How to convert XML type return text into select columns

I’m trying to get the column names of a table using XML datatype and information_schema columns. When I tried to use the result in another select statement, I have the results with the repeated column name instead of the results set. I have even tried to cast it to varchar but it still failed. what have…

ORA-00906: missing left parenthesis – LIES?

I have stared at this until my eyeballs bleed, where am I missing a parenthesis? It does also say Error starting at line: 1 in command-“. The cause and action section of the error report is blank. Answer This just because you missed column name while declaring primary key. There is another problem: cons…

TSQL to perform aggregation with Exists

My sample data source is following I want SQL to check if there exists any row with cond=X or cond=Y by site and if yes, don’t perform any aggregation; if no, perform a sum of val. I am currently achieving it by following Method1 Method 2 I was wondering if there is any better way of achieving this. Edi…

Compare the triplet rows together and select max of them?

Consider the following time series data These are the values of y, and the x column starts from 1 respectively. I have come to the conclusion that if the data in the y-column are compared three by three, the maximum value in each triad, is the peak point. Does anyone have an idea how to specify peak points wi…

SQL- Retrieve records based on column’s specific value

I have 2 tables with below info Table# 1 – TaskDependecy TaskID DependentTaskID 1 2 1 3 3 6 3 7 5 8 Table # 2 – TaskStatus TaskID Task Status 1 In Progress 2 Completed 3 In Progress 5 In Progress 6 Completed 7 Completed 8 Completed I want to retrieve only taskIDs # 3 and 5 so that

How to count active users using mysql

I’m trying to count active users in the last month by comparing the logged event against today’s date. So for example if a user logged in 2 days ago(09/01/2021), the query would evaluate to true since the logged in month 9 = todays month 9 AND logged year 2021 = todays year 2021. since its only us…