TekBytz

Tag: Conversion

Migrating Oracle Pivot Function to DB2/DASHDB

by on Aug.08, 2017, under Database

I have come across a situation where I need to migrate a ORACLE query which has a pivot function to DB2 equivalent SQL. The Pivot function is not available in DB2 or DASHDB. so was no direct solution in the internet and hence came up with my own solution

Sample Oracle Query with pivot function :

SELECT NM,DESC,ADM,USR,SUP
FROM
(
SELECT NM, DESC, GRP
FROM SRC_GRP
)
PIVOT
(
COUNT(GRP)
FOR GRP IN
(
'Admin' as ADM,
'User' as USR,
'Support' as SUP
)
)
ORDER BY NM

 

Converted equivalent DB2/DASHDB query:

SELECT NM,DESC,count(ADM) AS ADM,count(USR) AS USR,count(SUP) AS SUP
FROM
(
SELECT NM, DESC,
CASE WHEN GRP = 'Admin' THEN GRP END AS ADM,
CASE WHEN GRP = 'User' THEN GRP END AS USR,
CASE WHEN GRP = 'Support' THEN GRP END AS SUP
FROM SRC_GRP
)
group by NM, DESC
Order by NM

 

I was able to get the same output from both the queries.

Leave a Comment :, , , , , , more...

Live Currency Conversion For Multi-Currency E-Commerce Websites

by on Apr.15, 2016, under Internet, Links, Programming

If your E-Commerce website requires to display the product value in multiple currency based on user’s choice, it requires a conversion from base currency. This piece of utility will directly do the currency conversion based on live exchange rates. This utility used from google finance currency conversion module to perform the conversion and provide the output value.

Utility Usage:
http://currency.tekbytz.com/?amount=<amount>&from=<from currency>&to=<to currency>

Sample Usage:

http://currency.tekbytz.com/?amount=10&from=USD&to=INR

http://currency.tekbytz.com/?amount=20&from=CAD&to=EUR

http://currency.tekbytz.com/?amount=25&from=MYR&to=INR

The below currency format/codes are supported

  • United Arab Emirates Dirham (AED)
  • Afghan Afghani (AFN)
  • Albanian Lek (ALL)
  • Armenian Dram (AMD)
  • Netherlands Antillean Guilder (ANG)
  • Angolan Kwanza (AOA)
  • Argentine Peso (ARS)
  • Australian Dollar (A$)
  • Aruban Florin (AWG)
  • Azerbaijani Manat (AZN)
  • Bosnia-Herzegovina Convertible Mark (BAM)
  • Barbadian Dollar (BBD)
  • Bangladeshi Taka (BDT)
  • Bulgarian Lev (BGN)
  • Bahraini Dinar (BHD)
  • Burundian Franc (BIF)
  • Bermudan Dollar (BMD)
  • Brunei Dollar (BND)
  • Bolivian Boliviano (BOB)
  • Brazilian Real (R$)
  • Bahamian Dollar (BSD)
  • Bitcoin (฿)
  • Bhutanese Ngultrum (BTN)
  • Botswanan Pula (BWP)
  • Belarusian Ruble (BYR)
  • Belize Dollar (BZD)
  • Canadian Dollar (CA$)
  • Congolese Franc (CDF)
  • Swiss Franc (CHF)
  • Chilean Unit of Account (UF) (CLF)
  • Chilean Peso (CLP)
  • CNH (CNH)
  • Chinese Yuan (CN¥)
  • Colombian Peso (COP)
  • Costa Rican Colón (CRC)
  • Cuban Peso (CUP)
  • Cape Verdean Escudo (CVE)
  • Czech Republic Koruna (CZK)
  • German Mark (DEM)
  • Djiboutian Franc (DJF)
  • Danish Krone (DKK)
  • Dominican Peso (DOP)
  • Algerian Dinar (DZD)
  • Egyptian Pound (EGP)
  • Eritrean Nakfa (ERN)
  • Ethiopian Birr (ETB)
  • Euro (€)
  • Finnish Markka (FIM)
  • Fijian Dollar (FJD)
  • Falkland Islands Pound (FKP)
  • French Franc (FRF)
  • British Pound (£)
  • Georgian Lari (GEL)
  • Ghanaian Cedi (GHS)
  • Gibraltar Pound (GIP)
  • Gambian Dalasi (GMD)
  • Guinean Franc (GNF)
  • Guatemalan Quetzal (GTQ)
  • Guyanaese Dollar (GYD)
  • Hong Kong Dollar (HK$)
  • Honduran Lempira (HNL)
  • Croatian Kuna (HRK)
  • Haitian Gourde (HTG)
  • Hungarian Forint (HUF)
  • Indonesian Rupiah (IDR)
  • Irish Pound (IEP)
  • Israeli New Sheqel (₪)
  • Indian Rupee (Rs.)
  • Iraqi Dinar (IQD)
  • Iranian Rial (IRR)
  • Icelandic Króna (ISK)
  • Italian Lira (ITL)
  • Jamaican Dollar (JMD)
  • Jordanian Dinar (JOD)
  • Japanese Yen (¥)
  • Kenyan Shilling (KES)
  • Kyrgystani Som (KGS)
  • Cambodian Riel (KHR)
  • Comorian Franc (KMF)
  • North Korean Won (KPW)
  • South Korean Won (₩)
  • Kuwaiti Dinar (KWD)
  • Cayman Islands Dollar (KYD)
  • Kazakhstani Tenge (KZT)
  • Laotian Kip (LAK)
  • Lebanese Pound (LBP)
  • Sri Lankan Rupee (LKR)
  • Liberian Dollar (LRD)
  • Lesotho Loti (LSL)
  • Lithuanian Litas (LTL)
  • Latvian Lats (LVL)
  • Libyan Dinar (LYD)
  • Moroccan Dirham (MAD)
  • Moldovan Leu (MDL)
  • Malagasy Ariary (MGA)
  • Macedonian Denar (MKD)
  • Myanmar Kyat (MMK)
  • Mongolian Tugrik (MNT)
  • Macanese Pataca (MOP)
  • Mauritanian Ouguiya (MRO)
  • Mauritian Rupee (MUR)
  • Maldivian Rufiyaa (MVR)
  • Malawian Kwacha (MWK)
  • Mexican Peso (MX$)
  • Malaysian Ringgit (MYR)
  • Mozambican Metical (MZN)
  • Namibian Dollar (NAD)
  • Nigerian Naira (NGN)
  • Nicaraguan Córdoba (NIO)
  • Norwegian Krone (NOK)
  • Nepalese Rupee (NPR)
  • New Zealand Dollar (NZ$)
  • Omani Rial (OMR)
  • Panamanian Balboa (PAB)
  • Peruvian Nuevo Sol (PEN)
  • Papua New Guinean Kina (PGK)
  • Philippine Peso (Php)
  • PKG (PKG)
  • Pakistani Rupee (PKR)
  • Polish Zloty (PLN)
  • Paraguayan Guarani (PYG)
  • Qatari Rial (QAR)
  • Romanian Leu (RON)
  • Serbian Dinar (RSD)
  • Russian Ruble (RUB)
  • Rwandan Franc (RWF)
  • Saudi Riyal (SAR)
  • Solomon Islands Dollar (SBD)
  • Seychellois Rupee (SCR)
  • Sudanese Pound (SDG)
  • Swedish Krona (SEK)
  • Singapore Dollar (SGD)
  • St. Helena Pound (SHP)
  • Slovak Koruna (SKK)
  • Sierra Leonean Leone (SLL)
  • Somali Shilling (SOS)
  • Surinamese Dollar (SRD)
  • São Tomé & Príncipe Dobra (STD)
  • Salvadoran Colón (SVC)
  • Syrian Pound (SYP)
  • Swazi Lilangeni (SZL)
  • Thai Baht (THB)
  • Tajikistani Somoni (TJS)
  • Turkmenistani Manat (TMT)
  • Tunisian Dinar (TND)
  • Tongan Paʻanga (TOP)
  • Turkish Lira (TRY)
  • Trinidad & Tobago Dollar (TTD)
  • New Taiwan Dollar (NT$)
  • Tanzanian Shilling (TZS)
  • Ukrainian Hryvnia (UAH)
  • Ugandan Shilling (UGX)
  • US Dollar ($)
  • Uruguayan Peso (UYU)
  • Uzbekistani Som (UZS)
  • Venezuelan Bolívar (VEF)
  • Vietnamese Dong (₫)
  • Vanuatu Vatu (VUV)
  • Samoan Tala (WST)
  • Central African CFA Franc (FCFA)
  • East Caribbean Dollar (EC$)
  • Special Drawing Rights (XDR)
  • West African CFA Franc (CFA)
  • CFP Franc (CFPF)
  • Yemeni Rial (YER)
  • South African Rand (ZAR)
  • Zambian Kwacha (1968–2012) (ZMK)
  • Zambian Kwacha (ZMW)
  • Zimbabwean Dollar (2009) (ZWL)

Source : Google Finance

Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!