Skip to content

GROUP BY problem on WHEN in CASE statement

I’m trying to have the indirect and direct hours all show on one row and I know multiple rows are showing up because of the group by statement. However, I’ve tried removing the grouping and get an …

PostgreSQL count of each status per day

I have the following table: I also have a table with every calendar day from 2019-11-01 to 2019-12-31. I need to find out how many occurrences of each status exist per calendar day for the time span listed above. If a status is Opened on 2019-12-14 and Pending on 2019-12-17, I need to count that it was Opened…

Oracle SQL data fetch order

I’m trying to achieve this Layout. I’m not sharing the query because it’s working, I’m just wondering what functions to use in order to achieve format ‘2’. In the beginning I was doing UNION ALL , that’s how I got format ‘1’. The data is fetched from multi…

Sql check range exist between a range

i have a table like and i have a range value for example i want to get row who’s value matchs the range from database table Example minV = 5 , maxV = 15 should return first and second record Example minV = 5 , maxV = 35 should return all record Example minV = 5 , maxV = 9

Identity column as part of primary key

Suppose, I have a composite primary key that consists of 3 columns: [ShardKey], [SiteId] and [ServiceId]. Column [ServiceId] is an identity column and should start from 1 for a new combination of [ShardKey] and [SiteId], but SQL server fails – the column [ServiceId] never starts from 1, it just incremen…

Selecting variables as individual rows in table [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 2 y…

Problem when trying to create a table on SQL DEVELOPER [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 2 years ago. Improve this question I was trying to create a table on SQL Developer, and I had the error …