Is there a way to ensure first letter is capital in Snowflake for full name field?
Input : DAVID BILLY ALEX ANDERSON
Expected Output : David Billy Alex Anderson
INITCAP is what you are looking for:
select 'DAVID BILLY ALEX ANDERSON' as inp, initcap(inp) as outp;
INP
OUTP
DAVID BILLY ALEX ANDERSON
David Billy Alex Anderson
Related
Okay, I found many solution for many problems in Google Sheets, but this one is just hard as a rock. :)
I have a sheet where in column C are various names and in column D are professions. For example:
C / D
John Smith / plumber
Paul Anderson / carpenter
Sarah Palmer / dentist
Jonah Huston / carpenter
Laura Jones / dentist
Sid Field / carpenter
...etc
(as you can see every name are identical, but professions are repeating several times)
I'd like to see in column F the last matching name of the same profession
C / D / F
John Smith / plumber / (N/A)
Paul Anderson / carpenter /Jonah Huston
Sarah Palmer / dentist / Laura Jones
Jonah Huston / carpenter / Sid Field
Laura Jones / dentist / (N/A)
Sid Field / carpenter / (N/A)
...etc
It works fine with INDEX and FILTER function, but I have to copy the code over and over again as I add extra rows. This is the code I use:
=IFERROR(INDEX(FILTER($C4:$C,$D4:$D=D6,$A4:$A<A6),1))
I'm looking for a solution with Array Formula to autofill all cells in column F, and tried various versions (Lookup, Vlookup..etc), but couldn't find the right formula.
Any guidance would be appreciated. :)
try:
=INDEX(IF(C1:C="",,IFNA(VLOOKUP(
D1:D&COUNTIFS(D1:D, D1:D, ROW(D1:D), "<="&ROW(D1:D)), {
D1:D&COUNTIFS(D1:D, D1:D, ROW(D1:D), "<="&ROW(D1:D))-1,
C1:C}, 2, 0), "(N/A)")))
I am new to coding. Now I have a employee table looked like below:
Name
Hometown
School
Jeff
Illinois
Loyola University Chicago
Alice
California
New York University
William
Michigan
University of Illinois at Chicago
Fiona
California
Loyola University Chicago
Charles
Michigan
New York University
Linda
Indiana
Loyola University Chicago
I am trying to get those employees in pairs where two employees come from different state and different university. Each person can only be in one pair. The expected table should look like
employee1
employee2
Jeff
Alice
William
Fiona
Charles
Linda
The real table is over 3,000 rows. I am trying to do it with SQL or Python, but I don't know where to start.
A straightforward approach is to pick employees one by one and search the table after the one for an appropriate peer; found peers are flagged in order to not be paired repeatedly. Since in your case a peer should be found after a few steps, this iteration will likely be faster than operations which construct whole data sets at once.
from io import StringIO
import pandas as pd
# read example employee table
df = pd.read_table(StringIO("""Name Hometown School
Jeff Illinois Loyola University Chicago
Alice California New York University
William Michigan University of Illinois at Chicago
Fiona California Loyola University Chicago
Charles Michigan New York University
Linda Indiana Loyola University Chicago
"""))
# create expected table; its length is half that of the above
ef = pd.DataFrame(index=pd.RangeIndex(len(df)/2), columns=['employee1', 'employee2'])
k = 0 # number of found pairs, index into expected table
# array of flags for already paired employees
paired = pd.Series(False, pd.RangeIndex(len(df)))
# go through the employee table and collect pairs
for i in range(len(df)):
if paired[i]: continue
for j in range(i+1, len(df)):
if not paired[j] \
and df.iloc[j]['Hometown'] != df.iloc[i]['Hometown'] \
and df.iloc[j]['School'] != df.iloc[i]['School']:
# we found a pair - store it, mark employee j paired
ef.iloc[k] = df.iloc[[i, j]]['Name']
k += 1
paired[j] = True
break
else:
print("no peer for", df.iloc[i]['Name'])
print(ef)
output:
employee1 employee2
0 Jeff Alice
1 William Fiona
2 Charles Linda
Hi I can't figure this out for the life of me! On the second tab 'Combined' I'm trying to get the array to show a combination of unique dates, names and then a total of the amount to pay that person.
https://docs.google.com/spreadsheets/d/1sSuHK0h2OeaEJpraoHXTi01XIwpreM47BovQAV-snDE/edit?usp=sharing
So ideally it should show on the 'Combined' page:
A
11/15/2020 Bill Jones $553.80
11/15/2020 Steve Robinson $320.00
10/7/2019 Grady Johnson $100.12
11/15/2020 Grady Johnson $45.00
11/22/2020 Jim Luke $300.43
11/17/2020 Jim Luke $1,357.63
I've been trying to figure this out for days - please help!
use:
=QUERY(Investors!A4:C,
"select A,B,sum(C)
where A is not null
group by A,B
label sum(C)''")
I'm struggling with regular expressions at present, and I have a specific problem I need to solve.
Where a named value after Chief Investigator exists (Here Mr A Smith), I want to extract Mr A Smith only. I know that in all cases, 'Mr A Smith' will be preceeded and followed by two astericks.
"**Chief Investigator:**Mr A Smith
**Sponsor**: xxxxxxxxxxx
**Study Team Contact**: xxxxxxxxx
**Grant deadline**:
**Date EC meeting completed**: xxxxxxxxxx
**Upload Method**: xxxx
Any ideas gratefully recieved!
try:
=INDEX(TRIM(SPLIT(REGEXREPLACE(A1:A, ":\*\*|\*\*:", "♥"), "♥")),,2)
I am having a problem selecting a buyers name, products they bought, and price of items. I want the results to just show the buyers name once and list every product/price of said product.
Select distinct Buyer_First_Name, Buyer_Last_Name, Appliance_num, Price
from Buyer inner join Appliance
on buyer.Buyer_num = Appliance.Buyer_num;
This winds up listing the buyers name multiple times, as it is selecting all of the items distinct. The results I am seeing with this code is:
Buyer_First_Name Buyer_First_Name Appliance_num Price
John Smith 000001 $19.99
John Smith 000002 $45.99
John Smith 000003 $12.99
John Smith 000004 $17.99
Mike Brown 000001 $19.99
Mike Brown 000005 $33.99
Mike Brown 000006 $29.99
What I want to see:
Buyer_First_Name Buyer_First_Name Appliance_num Price
John Smith 000001 $19.99
000002 $45.99
000003 $12.99
000004 $17.99
Mike Brown 000001 $19.99
000005 $33.99
000006 $29.99
Thanks.
Hiding the duplicates is something you need to do in the presentation, not in the query. Look for an option in your reporting tool or adjust your code to do this.