I am trying to obtain the Index column (highlighted in yellow) that can count the number of times the product ID has iterated through 1 – 6 denoted by the Status Key and the tible is sorted in chronological order. For detail: The Product ID follows a chronological order denoted by the timestamp and the …
How to make dummy variables for a same data id in IMPALA SQL
I have a dataset in impala SQL like this: And I want to look like this: I have tried using CASE WHEN but results in duplicates for those ids where has 2 values different. Can someone help me with this issue. Thenk you much in advance. Answer
How do you UNION 2 tables based having a primary Key with different fields in either table?
Given this scenario: I have 2 tables, 1 named Books and the other Customers that look like this – The customers table has a BookTitle field that has the name of books the customer acquired from another Source (or they could be books they can manual enter into that field) The Books table can have the sam…
How can i get a gap from a history table for repeating groups over time
I have a historical table with data like as bellow : The EXP_DT is null mean that the row is active. I want to return a group of data each time Status changes The expected result like as bellow : Thanks for help ! Answer This is classic gaps-and-islands problem. We can solve it by using LAG to check for
Prevent Duplicate Entries in SQL Application
I have an application that’s running on two different machines. The use of the application is pretty simple, we scan a product and it associates the product_id and creates a Unique_ID that’s auto-incremental. Ex: U00001 then the next is U00002 My problem is while both the machines are running, som…
use sql case statement in a adoquery of delphi
so i want to calculate a sum of a field using adoquery and case statement in delphi ; the code i use is this : but i gest an error message : syntax error operator absent in the expression case when month(DATE_PAI)=1 then sum(MT) else 0 end can any one help me please Answer Try to do : (group SELECT
SQL Select Distinct Top5 with Order By and Where
I have a table where Employees can check assets and each of their checks is recorded in a table. Now I want to extract the 5 last checked Asset_Ids for a given employee. He might have checked the same asset more than once, each check is recorded in a table -EmployeeLog- Basically my table has 3 columns : Empl…
Problem with PostgreSQL function parameter of type “name”
I’m writing some PostgreSQL functions to compile a list of search terms for records in a table called name. Since the search terms come from multiple columns on the name table and from multiple columns on other tables, a simple generated column isn’t sufficient. Here’s a simplified version o…
How to convert SQL query in laravel query?
I know this question is not asked in a well manner way,so I am sorry,I have SQL query this one I want to convert it in PHP laravel query form so tried this query but I don’t know SQL and even I am not understanding how I convert it, can someone help just convert SQL query to laravel query? here
how to filter data in sql
I am trying to filter the data according to several criteria, and based on these criteria, the record record number 7 (M08) should not appear because the “NewSiteID” column is not null and does not belong to the number 6, but the problem is that this record appears even though I used the condition…