Below code works to combine Like and IN. But I need a column in the output with the values that I used for the Like: SELECT file_id FROM table1 as t WHERE archival_date = ‘20180108’ WHERE EXISTS(…
Tag: string
MONTHNAME in Portuguese MYSQL
I´ve got a huge query (In a PHP file) that gives me a monthname from some dates: Is there a way to insert my language inline with MONTHANAME? Something like: I don´t want to write case for eveymonth to transform ‘Dec’ to ‘Dez’ and so on, this will take too long. Answer Unfortunately in MySQL this cannot be done dynamically
Initcap of word
I’m having a table x it contain the column resource_name in this column I’m having data like NASRI(SRI). I’m applying initcap on this column it’s giving output Nasri(sri). But my expected output is Nasri(Sri). How I can achieve the desired result? Thank you Answer One possible solution is to use split() with concat_ws(). If value does not contain ‘()’, then
Deleting Part of a string in HIVE
I am trying to delete a part of a string in HIVE. I want to delete the last eleven characters for all records in a column. The data looks like: 1018492743|0001-01-01 I want it to look like: 1018492743 The code I have tried looks like: Select right(a.ord_id, len(a.ord_id)-ll) It isn’t working because len isnt a function in HIVE Another issue
How to run SQL queries in a loop
How can I run this SQL query multiple times in a loop, where I replace the word ‘pubs’ with another word during each iteration. Is there a way to store an array of strings and loop through them? Answer In general, it’s usually better performance-wise to do bulk or batch queries than queries in a loop, since you can save
How to create a huge string in Postgresql
For testing / debugging purposes, I need to get an enormous string into a field for one of my records. Doesn’t matter what the string is. Could be a million “*”s or the contents of Moby Dick…. …
SQL Server : ISNULL(compound NULL condition, ‘a string’) returns only the 1st character, under certain circumstance(s)
I’m a self-taught, vaguely competent SQL user. For a view that I’m writing, I’m trying to develop a ‘conditional LEFT’ string-splitting command (presumably later to be joined by a ‘conditional RIGHT’ – whereby: If a string (let’s call it ‘haystack’) contains a particular pattern (let’s call it ‘needle’), it will be pruned to the left of that pattern Otherwise, the
Split Full Name with Format: {Last, First Middle} Comprehensive Cases
My client sent me name data as a Name string which includes the last, first, and middle names in a single entry. I need them split into LastName, FirstName, and MiddleName. I have found some scripts online, but they don’t serve my purposes because they either (1) use a different format, or (2) don’t handle edge cases very well. See
oracle 12c – select string after last occurrence of a character
I have below string: So I want to select Sentence since it is the string after the last period. How can I do this? Answer You can probably do this with complicated regular expressions. I like the following method: Nothing like testing to see that this doesn’t work when the string is at the end. Something about – 0 =
How do I search for a five digit number in a string column?
What I’m trying to do is determine (Using Teradata SQL) if a person’s zip code has accidently been put on an address line. I’ve looked on various forums and I can’t find any similar questions. Ultimately, I would want to write something like: Any ideas? Target database is Teradata 13.x Answer If you want to inspect the entire column to