I have the following row on select I have to Identify empty jsons, then manually add a value to it (eg row 1 and 3 ), I tried the following : But the “is null” verification fails for this type of data (array of json), how to identify ‘[]’ values in this case? Note: I only have select p…
Tag: sql
Group SAS rows based on conditions
I am new to SAS community and need your help for one of my analysis. I have a table like below: ID VAR Group Breach Month 1 A 1 202001 2 A 1 202002 3 A 1 202003 4 A 1 202004 5 A 1 202005 6 A 1 202006 7 A 0 202007 8 A 1 202008 9 A
Many-to-many relation Laravel Eloquent. Fetch related table with specific related id
I am writing a query in Laravel 8 using Eloquent. There is a many-to-many relation between subjects and streams and their pivot table is courses. subjects: id name streams id name courses id subject_id stream_id I have to fetch subjects with specific stream. I have written the following query. $this->subje…
What query will return consumption per hour from SQLite data with cumulative value?
Firstly, I am almost a complete novice when it comes to SQL, so I am painfully aware I probably need to be spoon-fed anything but the simplest queries. I have been searching a lot, but most relevant examples I find seem to be too complex or general to help me with my problem. I have the following table in a
stack or union multiple fields in MS Access
Beginner’s question here… I have a table of tree measurements being 3 fields: – ID, Diameter_1, Diameter_2 & I wish to get to these 3 fields: – ID, DiameterName, DiameterMeasurement Input and Desired Output Though it results in only 2 fields. How may the field: – DiameterMeas…
How to insert data into table even if trigger fails?
Oracle 11.1 I have custom logging table where I insert data: I have a trigger that runs on a specific table which does some checkings. My problem is: when the trigger fails, I want to be able to log some data into the log_table. Trigger: The following code doesn’t work. I tried to use EXECUTE IMMEDIATE …
How to solve “SELECT list is not in GROUP BY clause and contains nonaggregated column” without adding the column into “group by”?
table: id action project_id created_on last_updated_on 1 Update 123 2021.1.1 2021.5.3 2 creation 123 2021.1.4 2021.5.2 3 Update 123 2021.1.3 2021.5.1 4 Update 456 2021.2.1 2021.6.3 5 Update 456 2021.2.2 2021.6.2 6 creation 456 2021.2.3 2021.6.1 I would like to get a map of project and its most recently create…
How to add split between duplicate value in SQL
I have SQL Server table that have duplicated value in field and need to split by slash character. All field start with alphabetical char end with ‘M’ char For example: and need to convert to: Thanks Answer Probably many ways to skin this cat, assuming you’re always looking for the same initi…
SQL query – split out count() results into one line of GROUP BY results
I want to use GROUP BY to get a row per month-year. Additionally, I have another field which, for this example, is colour and can have values of Blue or Red. I want to see a table with columns for Blue, Red, month and year = I want to count the number of each colour per month-year. Can I do
How to sum rows in groups of 3?
I have a table that looks like this: I need a query that returns the summed amount of rows grouped by every 3 consequent IDs. The result should be: In my table, you can assume IDs are always consequent. So there can’t be a 10 without existing a 9 too. But the same ID can also show up multiple times