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
How to create group by age employee in php myqsl
I want to create chart.js for avarage age in my company. But I can’t create the query. SELECT DATEDIFF(CURRENT_DATE, STR_TO_DATE(t.employee_birthday, ‘%Y-%m-%d’))/365 AS `ageInYears` FROM `employee` …
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…
Are the table indexes used in the select on the resultset of a subquery in the FROM clause?
I have a table in the SQL Server with more than 50 millions rows, so I have some compound indexes in my table. Indexes with 3, 4 columns. There is a situation where I really need to use a subquery in the FROM clause. example of the structure( the index is: column2, column3, column4 ): The example is only to
MySql Query to get certain number of values from limit and order by rand()
In below SQL query I need 25 rows containing product = ‘y’ and 25 rows having product = ‘n’. Product is a column having Y/N value only. In limit of random 50 rows I need 25 rows from each values. Kindly assist. I have tried Union but it didn’t work. Answer Simply use UNION for ea…
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 …