Skip to content
Advertisement

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

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

“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:

Advertisement