Query: results in code duration 234 3 345 2 345 3 456 4 567 5 567 6 567 1 I would like to add the durations of the same code and display results as here code duration 234 3 345 5 456 4 567 12 but I don’t know where to start with this query? Answer You can use GROUP
Tag: sql
Alter SQL column based on comparison of number of elements
I have a table with columns (Id, Prod, Id) and I must create a (Flag) like this: This (Flag) is created by grouping by (Id2) and assigning 0 for the lowest (Id) and 1 otherwise. I tried using group by to no avail. How can I do that? Answer You can use a case expression with a windowed function: Example
Get XY coordinates from GEOM_SEGMENT_START_PT() output
Oracle 18c: How can I get the X & Y coordinates from GEOM_SEGMENT_START_PT()’s resulting LRS point? Note: The coordinates are stored in the SDO_ORDINATE_ARRAY( ), not the SDO_POINT. Desired output: Normally, I’d use something like a.shape.sdo_point.x. But I don’t think that applies here since the coordinates aren’t stored in the SDO_POINT. Related: Oracle Spatial Community – Get X & Y
PYTHON SQLITE selecting multiple where conditions that may or may not exist
Working on some code that uses pysimplegui as the UI and SQlite for the data sorting. I’m using SQLite’s execute function to select data based on input from the user in the UI through variables. For example user wants to search for part name they input all or part of the name into the box, hit the search button which
Insert into table where id is not null and auto increment sqlite3
I’m trying to add some values into a table, but I get an error for not manually inputting the id. When I remove ‘not null’ the id just stays null Answer The answer Shawn gave worked, which is to remove AUTO_INCREMENT https://sqlite.org/autoinc.html
How do I create a trigger that will update a column if inserted or updated row is not null?
Table is EmployeeTest Column EmployeeCode has a Unique Index where it can allow NULL but cannot be duplicate. It is varchar (16) I want to update the EffectiveDate column I want to create a trigger for whenever I insert or update a row in the table, if EmployeeCode is NULL, then do not update EffectiveDate. If a row is created
Find position of first number in string and split
I am attempting to find the first numeric character in an ID composed of a client segment identifier (ABC_), a geographic identifier (UK) and a number (1234567). The ID will without exception follow this logic: ABC_UK1234567 From this, I need to extract the number only (the location identifier will have different lengths, as it could be ABC_UK, ABC_CHR or ABC_I
MS Access – How to properly use Pass-Through queries as source for form
In my MS Access FrontEnd connected to an SQL Server, I’m using a combination of pass-through queries and “normal” ODBC connection via file-DSN (for “easy bound forms”) for my forms. Within VBA functions and Subs I use some ADO connections to directly change data in the tables. I need pass-through queries for some forms as I need to use DISTINCT
SQL select items grouped by multiple values
I have table similar this one instance value type ins_1 31 “A” ins_1 81 “B” ins_2 72 “A” ins_3 9 “B” ins_3 9 “C” … and I need select only instance(s) which has double type (A,B). The expected result will be: [“ins1”]. Answer The typical approach here is to aggregate the rows per instance and use conditional aggregation in the
SQL Trigger for updating values from a query by id
I have three tables: employee with id(employee id), numOfTickets tickets with date, asset(id) and some more fields control with id(employee id), asset(id) when a new ticket is created it automatically inserts a row into tickets and control. Now I want to create a Trigger or something similar to automatically update the number of open tickets for each employee. A Query