SELECT
FirstName,
LastName,
Address,
FirstName ||' '|| LastName || ' ' || Address ||','|| City ||' '||State ||' '||PostalCode as [Mailing Address],
length(PostalCode),
substr(PostalCode,1,5) as [5 digit postal code]
from Customer
where
country='USA'
Tuesday, February 20, 2024
Truncating strings using substr function in sql
Concatenating strings in an user defined field in sql
SELECT
FirstName,
LastName,
Address,
FirstName ||' '|| LastName || ' ' || Address ||','|| City ||' '||State ||' '||PostalCode as [Mailing Address]
from Customer
where
country='USA'
Sunday, February 18, 2024
Example of case and calculated field in sql
select
InvoiceDate,
BillingAddress,
BillingCity,
total,
case
when total<2.00 then 'Baseline Purchase'
when total between 2.00 and 5.99 then 'Low Purchase'
when total between 7.00 and 15.00 then 'Target Purchase'
else 'Top Performer'
end as 'PurchaseType'
from Invoice
WHERE PurchaseType='Top Performer' and BillingAddress is not NULL
order by BillingCity
Sunday, February 11, 2024
Install nushell in ubuntu 22.04
Install brew firstsudo apt update
sudo apt-get install build-essential
sudo apt install git -y
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/$USER/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew doctor
Source:https://linux.how2shout.com/how-to-install-brew-ubuntu-20-04-lts-linux/
Then
For macOS and Linux, Homebrew is a popular choice (brew install nushell).
Source:https://www.nushell.sh/blog/2022-11-29-nushell-0.72.html
To start nushell
just type
nu
Saturday, August 12, 2023
Writing a list of lists in an excel file using openpyxl
import openpyxl
work_book=openpyxl.Workbook()
work_sheet=work_book.active
data=[["Champion","Year"],
['Uruguay', 1930],
['Italy', 1934],
['Italy', 1938],
['Uruguay', 1950],
['Germany', 1954],
['Brazil', 1958],
['Brazil', 1962],
['England', 1966],
['Brazil', 1970],
['Germany', 1974],
['Argentina',1978],
['Italy', 1982],
['Argentina',1986],
['Germany', 1990],
['Brazil', 1994],
['France', 1998],
['Brazil', 2002],
['Italy', 2006],
['Spain', 2010],
['Germany', 2014],
['France', 2018],
['Argentina',2022]]
for r in data:
work_sheet.append(r)
#save the work book
work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\world_cup.xlsx')