Skip to content

Tag: sql

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…

Count based on multiple conditions using sqldf

Hi all I’m writing a sql query on R using sqldf and seem to hit a roadblock. I have a table with an Id column, two dates columns and a grouping by column. The query I’m writing is From this query the result I’m getting is Whichis correct based on the query. What I want to achieve is if my

Oracle SQL merge tables side by side

I have 3 select queries which i would like to merge side by side. The common column is name. I dont want to use UNION ALL solutions since my select queries might have many columns. name columna e1 1 name columnb h1 2 name columnc t1 3 The output i am looking for is: name columna columnb columnc e1 1