I am starting out in SQL and am trying to do a query that will select all event names that are unique and do not have ‘TODAY-XXXXXXXX’ in the value for the event_name column. I have a query that works …
SQL’s union default order by clause?
I noticed when I am combining two tables via union that the order is not what I expected. calculus_class stats_class When I combine the two tables above I expect the results to be in order from top to bottom like this: This is the result I received using DBeaver PostgreSQL: Answer Actually, you are using unio…
change where statement given a case
I have a table which contains users info. with the columns: id_staff email id_supervisor id_branch id_department and I want to select the information in this table depending on a variable like …
Trigger for automatically updating email field?
I am trying to create a trigger which fires when a new row is inserted into my StudentInformation table without the Email field specified. The trigger should fire and update the email field with …
How to write a SQL query which uses the JSON format of table a_json to populate table b with its respective values in postgresql
I have a file named data.json. The structure is like this: { “PrimKey1”: { “layout”: “normal”, “col1”: “PrimKey1”, “__colll2__”: “sometext”, “col3”: 9, “OTHERCOLUMN”:”dontneedthis”, “&…
How do I fix this error: ORA-00933: SQL command not properly ended
Got this error while trying to enter values for 2 different tables on Oracle APEX and need help figuring out where I went wrong. I’m not sure if it’s because I made a typo somewhere or it’s because I’…
How do I get this JSON output?
I need to create the following JSON from SQL server 2016. { “recipientList”: [ { “name”: “1”, “recipientType”: “User” }, { “name”: “2”, …
Reset Postgres auto-increment value to 0
I’m having a table where I sometimes enter data in inline editors where I manually add the id value which is usually auto-incremented. In a case where id 4 was auto generated using scripts and then …
query for trunc(date) on a view that already filters for date
We’re accessing a view from another team’s database and to make it a lot simpler, the view looks a bit like this: create view x_view as select x.exec_time, … from stuff x where x.exec_time &…
Remaining leading zero after adding in sql
When employee_id is added by one, leading zeros are removed in the following query. SELECT SUBSTRING(MAX(ID), 6, 4)+1 FROM `employee` Here is my table. ID | Name ================= Empl_0001 |…