I have a table to find comma or pipeline present in the columns in teradata...any help would be appreciated.. please suggest generic query - teradatasql

Id Name address
123 mona #13,Jainroad|Mh
Here i have to find commas and pipeline in address column
Similarly i have to apply on different columns
Select * from table
Where col1 like '%,%';

Related

How to match a variable to a row in a dataframe and select the variable in a different column on the same row?

I have a bunch of chat logs and have managed to pull email addresses from them and seperate the domains "#bacon.edu" I have a list of domains matched with a category name.
Basically I want to match the variable to a row in the column 2 pull the category name from column 1.
I should mention everything is formatted as factors currently but that can change.
In this example d1 = "bacon.edu" and name list is a data frame set up like this:
d1 = "bacon.edu"
Workplace Name Email List
Pancake #bac.edu
Test place #toe.edu
superworld #bacon.edu
monkey gym #aclu.edu
toaster oven #yoyo.edu
The goal is to find bacon in row 3 create a variable from column 1 row 3(so abc = "superworld"), but i struggle to find the variable to begin with.
I have tried:
which(d1, namelist$Email.List)
which(namelist$Email.List == d1)
which(grep
match(d1, namelist$Email.list)
which(grepl("bacon.edu, namelist$Email.List
Sadly I dont recall all errors or what they came from but they include:
integer(0)
object class not logical
level sets of factors are different.
I have sense deleted failed attempts. Im sure its simple and I feel bad asking but any help would be appreciated!
We can use grep
namelist$1Workplace Name`[grep(d1, namelist$`Email List`)]

SQLite- Storing multiple values in same column

In SQLite , How would you store the information like this:
id name groups
1 xyz one,two
2 abc one
3 lmn two,three
The groups column may multiple entries. How can we store like that?
The main thing is the multiple values are should be appended.
I'm not sure I understand it correctly but why not store it as delimited string? Something like string1;string2;string3..or use comma instead of semi-colon like you already posted.
Just fetch the row, append the data followed by your delimiter and update the record. When you need the individual entries, just split the string using your delimiter.

Rows values as distinct comma separated values based on identifier

I have a table as shown below
ID|Name|Address|Pincode
I1|Ramesh|Hyderabad|1234
I2|Bhaskar|india|1234
I2|Bhaskar|srilnaka|124
I3|Prasad|india|1234
I3|Prasad|india|1235
I4|Chandu|malaysia|1236
I4|Veeru|india|1236
I am required only one row for each ID wise and name,address and pincode should be comma separated values of all rows group by ID.
I want to get out put as shown below
ID|Name|Address|Pincode
I1|Ramesh|Hyderabad|1234
I2|Bhaskar|india,srilnaka|1234,124
I3|Prasad|india|1234,1235
I4|Chandu,veeru|malaysia,india|1236
Help me oracle query for getting the desired result
Take a look at LISTAGG function. You just have to group by id and apply this function to name, address and pincode

How to exclude certain characters from like condition in Oracle

I Have multiple records in table like below. Each record holds mutiple entries separated by #.
record1 - 123.45.56:ABCD:789:E # 1011.1213.1415:FGHI:1617:J #
record2 - 123.45.56:ABCD:1617:E # 1011.1213.1415:FGHI:12345:J #
I need to pass an argument to a different project/service which builds an sql query and send the output to me.
Now if I send an argument like below, it gives me wrong output
123.45.56:*:1617
This recognizes both record1 and record 2 as proper output because of wildcard char. But as per my requirement only record2 is proper as record1 has 123.45.56 in one entry and 1617 in a different entry.
Is there a way to construct an expression that says the like condition to ignore such invalid entries.
Please note that I cant change the query as I am not constructing it. The only way for me is to tweak the expression that I can send as argument.
You need to restrict the pattern you match to be specic enough such that it only matches the first record and not the second one.
You can try:
SELECT *
FROM yourTable
WHERE col LIKE '123.45.56:' AND col LIKE '1617:J #'

Using the SQLite LIKE clause

Kindly review this simple SQLite-fiddle .
If any word in the column ITEM of table TWO matches any word in the column NAME_2 of table ONE, there should be a result(s).
Tried many permutes, yet not sure how to form the query for achieving this. Should the GLOBclause be used instead of LIKE, or perhaps some other wildcard patterns?
Many thanks in advance!
As per my comment, I think you can make use of instr as well. For example:
SELECT * FROM Table1 T1, Table2 T2 where instr(T2.NAME_2,T1.ITEM);
The above should return rows where T2.NAME contains a string = T1.ITEM

Resources