I have a sql table with a structure like this: Each column is a hour of day (I can’t change the structure of table) If I want to get the value of 13:00pm I have to write a query like this: SELECT …
Extract strings till the second delim SQL
I wanted to extract all the details till the second /(forward slash)from my table in SQL Server. Any ideas? Answer Perhaps this will suit your needs:
Create new PostgresSQL schema
What’s the easiest way to create a new Postgres scheme inside the database on the runtime and also, create the tables written inside a SQL file? This is a Spring boot application and the method receives the schema name that needs to be created for the db. Answer Although it sounds like this would be a c…
Find groups that are missing values of one column
Hopefully someone can send some light on an issue I’m trying to resolve. Types Codes I would like to be able to determine those Code/ID pairs that are missing a particular type. The result of this query should yield. Answer You need conditional aggregation for this: Another option is to cross join the p…
I am dropping the with check option constraint from view but it is not being enforced
So I am stuck in a problem. I defined a view with the WITH CHECK OPTION constraint, now i wish to delete it, but even after dropping the constraint i get the error :=ora-01402: view WITH CHECK OPTION where- clause violation. this is the sequence of SQL commands i am executing – I cant figure why this is…
Error(8,1): PLS-00103: Encountered the symbol “SET”
I’m trying to create a function using oracle, it should be working fine but i keep getting the following error: Error(8,1): PLS-00103: Encountered the symbol “SET” here is my Function: Answer The problem is where do you put this command: SET SERVEROUT ON; cause its inside the function declar…
How to split sql query results into new incremental tables
I am using the following code to create a HTML table which works great to produce a table ordered by position based on points. However, I would like to sub divide the results into different tables …
SQL Server : proper join of data with return of preferred value if present
I’m working on multiple data tables, trying to figure out the best method of joining them. I’m using a primary table (let’s name it Devices) along with additional ones, Settings. All mentioned tables …
Ordering within a json_agg of json objects
I have a simple query as follows: select json_agg(json_build_object( ‘name’,’name’, ‘score’,random(), ‘snippet’,’random text’ )) as data …
oracle grouping everytime the sum amount is below 15
I’ve following data: SELECT 1 note, 1000 amt FROM dual union all SELECT 2 note, 2000 amt FROM dual union all SELECT 3 note, 8000 amt FROM dual union all SELECT 4 note, 3000 amt FROM dual union all …