There are two tables. Table A : id name 1 nameX 2 nameY Table B : id aId name 1 2 Foo 2 2 Bar Ask a SQL: when search ‘nameY’, get A.id A.name B.id B.aId B.name 2 nameY when search ‘Bar’, …
Tag: sql
Extract partial data from a column using SQL (and maybe regex)
I’m working with SQL in MS Access. One of the columns that I import from Excel has date and time in an odd format as below: Jan 12 2021 07:55:14 AM PST MS Access doesn’t recognize this as date and …
Invalid column name using sp_MSForEachDB in SQL Server 2016
I am attempting to query multiple databases housed on the same SQL Server instance using sp_MSForEachDB. There are 8 databases that have the table man_days with a column named servicetype. I have …
Insert only selected field with multiple value into one value with delimiter
I have two tables, one is to record the queue, another one is record the data for each queue Queue Table Id Queue_Id 1 1 Data Table Id Queue_Id Item Field 1 1 A Vege 2 1 B Fruit 3 1 A Vege 4 1 B Fruit Now I have to create a stored procedure that will return a temp
How to get all data post midnight of different timezone?
I have a PostgreSQL table named testing with a column named creation_time as timestamp with time zone. The database timezone is UTC Now I want to get all rows whose time is greater than 00:00 of the current day as per the timezone “America/New_York”. I know how to get all rows after local midnight…
SQL extracting date substring using regexp_subtr
I’ve got a field named signal_notes containing strings like the follow (this would be a single value of signal_notes): Sometimes, the ^expiry_date^ line will have a date between the ^’s in the format ‘YYYY-MM-DD’. My new field expiry_date will ideally be in the format ‘YYYY-MM-DD…
Find Previous Month MTD (Month to Date) Calculation in BigQuery
Assuming I have initial table of date and each order value of the date: So I use this query for calculating current MTD (cumulative gross order in a month from day 1 of certain month to certain date in that month), the result will be something like this: The idea is to also have value of previous month MTD va…
SQL: Updating 2 different columns in table from CTE condition
Hi I have a temp table with 2 different columns that I am trying to update from a CTE that has a boolean column ‘uninstalled’. As in: I then want to update the table ‘temp_customers’ above from the CTE and their respective columns (where uninstalled = true shall update column ‘ap…
Query works but cant retrieve the data
I am new to Node.js (3 days total experience). I am using Node.js and the tedious package to query a database (azure SQL). I use the example as explained here: https://docs.microsoft.com/en-us/azure/…
Condition OFFSET on SPLIT in SQL
I am using SQL on Google Big Query. I have a column MyColumn which value is in this format : Text0;Text1;Text2;Text3;Text4;T12=12/T26=5/T13=1/T55=ABC I need to fetch the value of T13 (“1” …