Skip to content

How to flatten Rows into Column (Field) Values

I have data that has Job_ids split across multiple rows (i’ve had to do this because previously i’ve had to split out team members from each job_id, then identify their teams The format my data is currently in is as follows, (not shown) but each job_id has an employee who has a team assigment, and…

Hive – Merge rows with search term substrings

I got a search results log table with search terms in one of the columns. Since the search results are produced as the user types in the search terms, there are multiple rows for each search term with the partial string. For example, as the user types world the resulting rows in the table will be: Expected re…

Add auto_increment feature to a primary key

I have a problem related to sql language. I am trying to add the auto_increment features to a pre-existing row with the primary key attribute. What I get back is : Error Code: 1833. Cannot change column ‘ODB_ID’: used in a foreign key constraint target_ibfk of table ‘test3.target’. The…

Querying JSONB array value for sub values?

I have a JSONB Object: It is stored in a jsonb column of a table So i was trying to get a count by name of devices which have interfaces that are not ‘up’. Group By is used for developing counts by naame, but i am having issues querying the json list for values. MY first Attempt was: Some surround…

Conditional join on soonest date – SQL Server 2017

I am working with two tables: tblOrders and tblPOs I am trying to join these two tables, and for each order, select the PO with the earliest arrival date (in the event there is more than one). So for Order Number 10244, it has two POs, PO99455 and PO99456. I would want PO99456 to be associated, since it&#8217…

Finding double bookings

I have two tables which when linked by a booking ID from table 1 and ID from table 2 Therefore Im trying to flag double bookings where the same member id has booked twice within a time frame (StartDateTime and EndDateTime). Then remove the booking that has the latest BookedDate. Can someone help me with a sql…