Struggling with ms-access’s flavor of SQL queries still, though I’ve made some progress (thanks to y’all). I have an event log table like this: Logs Table logID (auto#) modID (str) relID (str) DateTime (date) TxType (short) 1 1234 22.3 10/1/22 0800 6 2 1234 22.3 10/1/22 0900 7 3 1234 22.3 10/1/22 1000 13 4 1234 22.3 10/1/22 1100 15
Tag: sql
SQL get the value of a nested key in a jsonb field
Let’s suppose I have a table my_table with a field named data, of type jsonb, which thus contains a json data structure. let’s suppose that if I run I get so in pretty formatting, the content of column data is I know that If I want to get directly in a column the value of a key (of “level 1”)
How to compare two tables and if the values match, update one of the tables with the values from a third table?
I have 3 tables, the MAIN_TABLE, the SUB_TABLE and the ID_TABLE. I need to compare the CODE in the MAIN_TABLE with the CODE in the SUB_TABLE, and if they match, search for the SUB_ID in the ID_TABLE and update the ID in the MAIN_TABLE with that ID. In the example shown below, the query should update the MAIN_TABLE with the
Compare two VAT numbers
I`m trying to list only the vat numbers which look like DDDDDDDDDLLDDDD else i have to list NULL https://i.stack.imgur.com/4PYR8.png Pretty sure that I`m close but still missing something 🙁 Answer You can use the regular expression ^d{9}[A-Z]{2}d{4}$ to match the start-of-the-string, then any 9 digits, then any 2 upper-case letters, then any 4 digits and, finally, the end-of-the-string: If you
Export Data from Azure SQL Server SP or table to Excel using Azure Resources
I am having few data which gets returned from my Store procedure or table from Azure SQL Server, Client is having some formatted excel and I need to export data from SP to that formatted excel. The excel has pre defined columns with different name than DB Column names . Is it possible by using any Azure resources like Azure
Problem with Ambiguous Column Name in SQL script
I am new to SQL and using this online compiler. https://www.programiz.com/sql/online-compiler/ I have the following script and I am getting the error: Error: ambiguous column name: Customers.customer_id There is a customer_id column in multiple tables, but I am specifying which table to pull each column from. Why is it still saying it is ambiguous? Answer An UPDATE statement with a
SQL – count rows between dynamic number of date ranges
I have a table to store events like this: and another table to store posts like this: if I want to get count of posts that happened during a single event I can write: but how can I get the count of posts that happened during multiple events, when the target events are only known at runtime? Edit: the database
dates from the DATEDIFF()
I am using the query in Snowflake: It gives me no. of days as: days start_date end_date 14 2022-09-03 2022-09-17 28 2022-08-19 2022-09-16 but I need to find the dates for the days instead of just the no. of days i.e I want to see those all 14 dates instead of just no. of days. can anyone help. Answer so
PostgreSQL : Hint: No operator matches the given name and argument types
When I execute my query I have this error : Query failed: ERROR: operator does not exist: “GOOD_RECIEPT_ANOMALY_DETECTION_V2_last_alerts_sent_gsheet_histo” > timestamp without time zone Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 176 Here is my SQL query : I work on PostgreSQL database. I think the problem comes from
How unnest h2 table’s result
I have this field now in h2 want to select it but it doesn’t work Answer UNNEST in SQL is not a regular function, it is a collection derived table. You can use it in the FROM clause: