I have a table that shows date ranges of an object. For reference The object needs some sort of event in order to prevent it from expiring. We have a rule where we can apply a protection against the object from expiring, so that there is no need to action the object. The date ranges are a period of time
Tag: sql
Big Query Error When Using CAST and determining decimals
I have linked a Big Query Project to my Google Ads Account. Within that, we have a campaignBasicStats table. I want to pull the cost of a campaign from my Google Ads account into a big query workspace to apply some additional logic. The cost column is coming through as an INTEGER and is described like this: INTEGER NULLABLE The
SnowflakeSQL get me last text after specific char
I’m trying to retrieve last part of string after underscore.. but every record has different number of underscore and I’m not sure how to write it correctly. Example: aaa_bb_cccc_dddd_ee – only ee aaa_bb_cccc_dddd – only dddd sss_aas_ww_ww_ww_bb – only bb As you can see there is different number of underscore and I need only last part after last underscore. I
How to Convert Array or String in Snowflake to Timestamp_NTZ
I currently have some incoming datestamps as from outside datasource, but am struggling to define them in a table through my Snowflake Tables. The column is formatted as such: {“type”:”TEXT”,”length”:12,”byteLength”:48,”nullable”:true,”fixed”:false} The only current workaround I have is this convoluted code. Any suggestions to convert string to integer for timestamp? Answer Assuming the format of input ‘YYMMDDHH24MISS’ and first 22 stands
how to get slice of an array in AWS Athena?
I have an array of unknown length in AWS Athena. I want to get all elements expect for the first one and concatenate into a string. I can do with a known length, but I don’t see how for unknown length. In this example: What I want is myslice_joined. I could use slice because I knew it had four elements,
Is my understanding of how FIELDQUOTE works correct?
I am using Azure Synapse and I m querying the following CSV file: Here is the T-SQL query: Here is the output: I then altered the CSV file to add a colon just before the letter G as so: I get: This lead me to make the following conclusions about FIELDQUOTE: The query as a whole scans each row, character
Replace multiple variables in R Sql Query
I have a query similar like the one below where I need to use multiple string of characters to replace in a single query. I am not too sure how to make sure a and b are passed into the %s in the query. I am getting the error ‘unused arguments (b)’ Any advice please? Thanks Answer sQuote only takes
Oracle db. How to get a result set of unique values of pretty much arbitrary amount of columns of the same table
Having this column structure Is it possible to get one-column output with unique values? What I’ve already tried: Union seems doable only in case there are 2 to 3 columns, which is not the case. I’ve found a pivot/unpivot, but I didn’t really grasp it. Answer If you must handle null also, you can do so with the include nulls
list records which do not meet a certain criteria in Oracle SQL
I got 3 tables please see the below. Currently, a car has a unique tag assigned to them. I have employees with multiple roles. There are only 3 roles. 1 = Surveyor, 2 = Admin or 3 = Engineer. A car can be assigned to more than one employee. One car can have a surveyor, admin and engineer using it.
Compare Between two value in different UOM
I try to build Report on Power Bi to show the comparison between Sales achieved per items and Targets per items but the sales in many UOM and the Target in one UOM How can i do it ? Answer The usual approach is: define a Item_UOM table which lists all possible UOMs for each Item, with a conversion factor