My table in snowflake has a column with string values. The string has comma and slash. I need to list only the values before first comma or slash. I used snowflake SPLIT function, with that i could only get rid of either of one (comma or slash but not both) character.
Input values:
Compact SUV/Crossover
Luxury Subcompact SUV/Crossover
Subcompact Car,Sports Car
Luxury Car,Luxury Sports Car
Compact Car,Hybrid/Alternative Energy Car
Entrylevel Luxury Car
Midsize Car
Desired output :
Compact SUV
Luxury Subcompact SUV
Subcompact Car
Luxury Car
Compact Car
Entry level Luxury Car
Midsize Car
A simple regex should help:
select regexp_substr(s, '^[^,/]*')
from (
select 'Compact Car,Hybrid/Alternative Energy Car' s
)
https://regexr.com/6ejld
Related
I'm very new to Access. What I'm trying to do is create a database for songs which I will use to automatically create PowerPoint slides.
Most of the songs will be in Chinese, and the database will contain fields such as song name, number of characters in song name, number of strokes of first character of song name, verse 1 lyrics, verse 2 lyrics, chorus 1 lyrics, chorus 2 lyrics, etc.
I have an Excel file with the first column containing single characters and the second column containing the number of strokes of the character. I've imported this into Access as a table.
How do I get Access to automatically fill in the "number of characters in song name" and "number of strokes of first character of song name" fields for a record once I fill in the "song name" field?
I would prefer editing the database directly without using forms.
If you create a Query then use a Calculated Field.
You can use LEN to get the Length of Field.
You could use the SPLIT function to split your song name on spaces then get the len of the first item.
I have been looking and doing research, and I am having trouble trying to split a table to two files, where one file only have English letters and special characters (such as ,.& () 0-9 - etc) and a second file that has all the records that have a foreign letter.
I have tried veriations of
SELECT * FROM TABLE WHERE Column_name like '%[a-zA-Z0-9]%'
but that would not get special characters
also
SELECT * FROM TABLE WHERE Column_name like '%[\040-\176]%'
The data looks like this (not actual Data)
Doha, The Black Pearl
Jefferson City & Wells
Wenston 89-100
St. Winchester (T)
Piñata Valley
Not süre how to Üse that U
I have 4000 records and want to quickly look through the table. I want all the records but the last two.
You're looking for REGEXP or RLIKE, not LIKE.
Excel wiz's,
I'm trying to build a report with a simple drop down list of names. Rather than try to explain in more detail, let me give you a sample dataset:
Table1:
Text Person1 Person2 Person3
String here contains name(s) Mike Smith Robert Johnson Suzy Q
Another string with name(s) Dan Boy John Michael Bob Wise
Different string with name(s) Robert Johnson Suzy Q
In my report sheet, I have a drop down list of all the possible "persons" that I want to chose from and then return all values from the "Text" column in an array. I have been able to make it work with only one column using this formula, where C4 contains my choice in the dropdown list:
INDEX(Table1[#All],SMALL(IF(Table1[Person1]=$C$4,ROW(Table1[Person1])),ROW(1:1)),1)
The text column will contain all the names of the Person columns, but they are in a different case (all caps, can't change format for display purposes). Maybe a SEARCH function would be more useful? I'm not sure. I'm trying to avoid using a macro, but I am not completely opposed.
Let me know what you guys think, and thanks in advance!
Simply re-organize your table so that there's one row per name... the V-Lookup on the name and get the matching list.
Person Text
Mike Smith String with names
Robert Johnson String with names
Suzy Q String with names
Dan Boy Second string with names
are you trying to make validations for teams? like select team, then next drop down gives only members of that team?
you can use offset inside validation. in one cell put a validation for the list of teams. in the other cell, create a list validation, use a offset formula to return the range of members based on the selected team.
edit: not sure how to put in a table, but this is how you would fill a range with vlookup
in the table with the entries, add a column with serial number starting from 1-n
just below the drop down box, enter numbers 1 to n in order
vlookup the serial number in the table, that is the row you are looking up
for the column, use a match to look in the table which column the current selected person is
drag the formula down to fill n numbers
I have a set of 3 parameters each can take 3 values
eg.
paramerets value1 value2 value2
country india US UAE
language hindi english urdu
currency Rs Dollar Dinar
based on above i have saved records like
Name country language currency
A india hindi Rs
B US hindi dollar
C UAE english Rs.
D india english Rs.
Plus i have a few filters declared as follows:
Filtername country language currency
Dont_care_filter Any Any Any
A_Bit_Stringent_filter India,UAE hindi,english Rs.
Unique_filter India hindi Rs.
Now I need an algorithm to find the perticular filter a record belongs to?
( I case a record belongs to more than one filters it should be related to the more stringent filters ie having fewer number of values for each parameter )
what I have thought till now is represent these values of different params in form of ascii codes.
And what i need...
Is a hashing algorithm that can map one to many values ? i.e. I feed param values of one record, it matches with the precalculated hashes of all the filters declared and gives me the filer which contains the param values of the record.
I am new to database programming and am using sqlite and python. As an example lets say I have a database named Animals.db which I open with and get the cursor for in python. Now if I wanted to separate the animals by species I would have a different table per species and since it can get even more specific I would likely need something more specific than just a table of species.
I am a bit confused on how one allocates the correct data to the correct area of a database, how is it separated. Are there tables of tables?
if I wanted to lets say have a table for every land animal and another for every animal of the sea, but each table would need further specification(homo sapiens, etc), how can I do that?
Now if I wanted to separate the
animals by species I would have a
different table per species
Maybe. Maybe not. You might use a table that looked like this. It depends entirely on what you mean by "separate the animals by species". Here's one reasonable interpretation.
Animal_name Sex Species
------
Jack M Leopardus pardalis
Susie F Leopardus pardalis
Kimmie M Leopardus pardalis
Susie F Stenella clymene
Ginger F Stenella clymene
Mary Ann F Stenella clymene
To find all the Clymene dolphins, you might use a query along these lines.
select Animal_name
from animals
where species = 'Stenella clymene'
order by Animal_name
Animal_name
--
Ginger
Mary Ann
Susie
Start by collecting data. Your goal is to collect a set of representative sample data. Sample data, because the full population is too big to handle. Representative, because ideally it represents all the problems you're likely to run into with the full population. If "animal name" to you doesn't mean "Jack" or "Ginger", but "ocelot" and "Clymene dolphin", representative sample data will make that clear.