Here are my two tables’ structures in SQLite if startJob is 1 it implies that the employee is starting the job and if startJob is 0 it means employee is stopping the job. attendanceTable is sorted by mydate column I want output as worked hour by individual employees. Input of query can be two different …
Tag: sql
Divide the sum of grades using pivot operator
Output: Expected output: Answer Each student may have two marks in each subject? Make sure of that first of all Try to use the average AVG(Grades)
SQL Query : Column1 – Stores_id, Column2 – Repo_id. How to select stores with more than 1 repo?
I would like to select only stores_id with more than one repo_id. In the case below, I would like as a result: Stores 1 and 4, as they have 2 repos_id related to them. Example Table Answer If I understand you Question correct here would be a small example with having:
Postgresql column reference is ambiguous
I want to call my function but I get this error: ERROR: column reference “list” is ambiguous LINE 3: SET list = ARRAY_APPEND(list, input_list2), the error is on the second list inside array_append function. My function: Answer You have to use the alias name in the insert query because list has two…
Hourly average for timestamps columns – FROM keyword not found where expected
I would like to get the hourly average of two columns. The type of the columns is timestamp. I try this: I do not know if this is the right way to go at all. But the query is not correct. I get this error: 00923. 00000 – “FROM keyword not found where expected” In the end I would like
Create new column with all unique values from another column in SQL
I have the following table: I want tto create new table which will show the unique crop names, count of the crops appearence and then list of all the growers that grow this crop,so the result table should look like this: I manage to create table that shows the crops and the total count without the growers nam…
How to use CASE statement to update data (as fractions) in the table?
Query Table: Different Fruits Total Fruits Fruits Fraction 3 5 2 6 2 2 4 6 1 1 6 6 6 16 4 20 Updated Table: Different Fruits Total Fruits Fruits Fraction 3 5 3/5 2 6 2/6 2 2 2/2 4 6 4/6 1 1 1/1 6 6 6/6 6 16 6/6 4 20 4/6 There is a total
Group By based on consequtive flag in Redshift (Gaps and Islands problem)
I am trying to solve “gaps and islands” and group consecutive checks together. My data looks like this I want to group by consecutive location_id and consecutive reservation_id (both should be consecutive respectively) within same date and site_id, and sum revenue. so for the example above the out…
MySQL match a value with wildcard in multiple columns
I have a teachers table that looks like this: teacherid teacherfname teacherlname salary 1 Alexander Bennett 55.30 I would like to return any record that contains a given string in the teacherfname, teacherlname and salary columns. What I have right now (this returns exact match only): What I would like to do…
SQL UPDATE SET SELECT slow [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 7 months ago. Improve this question I ha…