I have a requirement where I need to eliminate all the rows which have returning flight routes. I have highlighted the routes in the orange color which depicts this behavior. For example, row 1 has one route BKI – MYY and row 4 has MYY – BKI. I need a flag (Boolean 1/0) that checks the entire row and sees
Category: Questions
How to ungroup the grouped record based on count column using SQL
I have below data set obtained after group by dept and loc. dept id loc count 100 a 2 300 c 1 I need out put like below deptid loc 100 a 100 a 300 c please help Answer Another option is to use Recursive Queries to get the desired result. DB Fiddle Link: https://dbfiddle.uk/?rdbms=oracle_18&fiddle=0580680ecf0b47b4933e3a4731b62b4a
Sql conditional Join statement
I have this sample I want to code this case in sql : When i have a null value in “ASS_OT_Traveaux.CodeEquipement” it doesnt show any data Answer
Unique Indexes query for HSQLDB
I’ve got a query that selects unique indexes from a MySQL DB table: I am looking to create the equivalent query that works for HSQLDB Any help is much appreciated! Answer That’s available in information_schema.system_indexinfo
sql – union tables with same prefix
I have a set of tables with same prefix and same structure. All I need is to “combine” them as one. Basically I retrieve tables with certain pattern from information_schema.tables, then get rid of the last union all. Above method works for 20-30 tables, as the @result won’t exceed the limit for nvarchar. But I’m curious how to get this
If a column is not null then convert into a row for multiple columns
I have a table like below where I looking to transpose col4 col5 and col6 into rows but in a specific pattern that I listed below col1 col2 col3 col4 col5 col6 a b c 500 200 w x y 1000 300 z g h 200 600 I want to convert it to the following col1 col2 col3 col4 col5
“Flattening” complex sequences of related rows in SQL
I have a table with events describing user navigation through flows, with this general shape (disregard the timestamps, I smashed some keys): After the option_a event, users can go back and choose another option: Users can also go through a flow multiple times: I want to produce a table where each row represents a flow, from start to end, including
Conditional update with jsonb_set()
I have a table in a Postgres 11.3 database with a jsonb column. Trying to update all objects inside a nested array name “iProps”. If the path {iProps -> value -> rules -> ao -> sc} is an object, then the path should be updated from an object to a string with the value {iProps -> value -> rules ->
Pick the max value of id from multiple tables
I have 3 tables. Each of them have id column as PRIMARY. There is no relation between tables. I want to make a query which gives me the max id of every table. What I have tried was this: But I get NULL, NULL, NULL. It is possible to done that? If yes, how? Answer MySQL syntax supports placing subqueries
tsql – pivot sum of employee
I have here a sample table data which i want to use pivot and make my DedCode data into column. the AMount example is already computed to its total but how can i count the number of employee if it is same with branch,deptcode and emptype. my sample table data. expected output: Answer You can use conditional aggregation: