I am trying to return a list of slow-moving stock items. Whenever there is a sale, the items are written to the saleItems table. I want to get those items from inventoryMaster table that are not …
Pivot rows into column Googlesql
I have a data like below ID name timeSpent_in_mins 1 ABC 12 1 XYZ 24 I need something like ID ABC XYZ 1 12 24 Need something similar to Pivot in googlesql/standard sql Thanks In …
Merge groups of consecutive rows in T-SQL and sum values from each group
Updated 10/08/2019: @Gordon Linoff: I have tried to applied your solution but I realized that is not working as expected. I have added an example with expected result with comments here (https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=1b486476d6aeab25997f25e66ee455e9) and I would be grateful if you could…
get the count of unread messages
I have this requirement with our DB like shown below I want to get the 3 columns requestType, CategoryGroup, and count of readStatus column The result will show all the requestType along with …
How does this SQL query return results with same id_product?
I am facing a complex SQL query in some code, which is suppose to return products without duplicates (by the use of DISTINCT keywork at the beginning), here is the query: SELECT DISTINCT p.`…
SQL GROUP_CONCAT query assistance
I am having some problems figuring out the best use of GROUP_CONCAT. In the query below I am trying to select multiple images from JAM_Plot_Images and set them against single records. So get record …
Select max data in interval of 1 hour within a time range in sql
I have some difficulties with sql server to select max value in a column in interval of 1 hour within a time range. My table look like this: +———-+——-+———————+ | Id | …
Select query in SQL SERVER need to support
I have 3 tables like that: – Employee_Table (Employee_Number, Employee_Name, Department_Number) With Employee_Number is PRIMARY KEY, Department_Number is FOREIGN KEY; – Employee_Skill_Table (…
Apply different Adjustment Factor for different date range
I have a Table with SalesPerson and Sales for different dates. I have another table where I have SalesPerson and multiple date ranges where different Adjustment factor needs to be applied. I can do …
PDO changes query
I want to have result of my query as it was before I replaced db connection using PDO. How can I get the query as i t was before I implemented PDO? This is my query: $query = “SELECT `…