SlideShare a Scribd company logo
1 of 3
Download to read offline
My step by step installation and problem fixes of MySQL
Statistical UDF – Median.

Wikipedia: “In probability theory and statistics, a median is described as the numeric
value separating the higher half of a sample, a population, or a probability
distribution, from the lower half. The median of a finite list of numbers can be found
by arranging all the observations from lowest value to highest value and picking the
middle one. If there is an even number of observations, then there is no single
middle value, so one often takes the mean of the two middle values.”

Approach for obtaining Median, the middle most value, earlier was as follows:

Create a temporary table to obtain middle most value(s) and then take average of
them.

1. CREATE TEMPORARY TABLE medians SELECT x.val FROM data x, data y GROUP BY
x.val HAVING ((COUNT(*)-(SUM(SIGN(1-SIGN(y.val-x.val))))) <= floor((COUNT(*)
+1)/2)) and ((COUNT(*)-(SUM(SIGN(1+SIGN(y.val-x.val))))) <= floor((COUNT(*)
+1)/2));

2. SELECT AVG(val) AS median FROM medians;
[As suggested by Kreaseck.]

But Median-UDF has brought us to ease in getting median value easily.

Following is a kind of snap shot / steps I executed on my linux- ubuntu box to get
the Median UDF working on MySQL 5.0.
I faced approx 3 minor errors which I got resolved; they’re also included in steps.

root@krex:~/mysqludf# wget
http://www.mooreds.com/files/mysql-udf-patched.tar.gz

root@krex:~/mysqludf# ls
mysql-udf-patched.tar.gz

root@krex:~/mysqludf# tar -xzf mysql-udf-patched.tar.gz

root@krex:~/mysqludf# cd mysql-udf/

root@krex:~/mysqludf/mysql-udf# ls
udf_colwidth.cc udf_correlation.cc udf_intercept.cc
udf_median.cc udf_slope.cc udf_weightedavg.cc
udf_confidence_higher.cc udf_faculty.cc udf_kurtosis.cc
udf_noverm.cc udf_stdnorm_density.cc
udf_confidence_lower.cc udf_geomean.cc udf_longest.cc
udf_skewness.cc udf_stdnorm_dist.cc
root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I
/usr/include -I /usr/local/include -I /usr/local/mysql/include/ -o
udf_median.so udf_median.cc
udf_median.cc:31:23: error: my_global.h: No such file or directory
udf_median.cc:32:20: error: my_sys.h: No such file or directory
udf_median.cc:34:19: error: mysql.h: No such file or directory
udf_median.cc:35:21: error: m_ctype.h: No such file or directory
udf_median.cc:36:24: error: m_string.h: No such file or directory

root@krex:~/mysqludf/mysql-udf# locate my_global.h
/opt/lampp/include/mysql/my_global.h

root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I
/usr/include -I /usr/local/include -I /opt/lampp/include/ -I
/opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
In file included from udf_median.cc:31:
/opt/lampp/include/mysql/my_global.h:353:24: error: asm/atomic.h:
No such file or directory

root@krex:~/mysqludf/mysql-udf# locate atomic.h
/opt/lampp/include/atomic.h

root@krex:~/mysqludf/mysql-udf# mkdir /opt/lampp/include/asm

root@krex:~/mysqludf/mysql-udf# cp /opt/lampp/include/atomic.h
/opt/lampp/include/asm/

root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I
/usr/include -I /usr/local/include -I /opt/lampp/include/ -I
/opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
/usr/bin/ld: /tmp/ccimPFiX.o: relocation R_X86_64_32 against
`compare_doubles(void const*, void const*)' can not be used when
making a shared object; recompile with -fPIC
/tmp/ccimPFiX.o: could not read symbols: Bad value
collect2: ld returned 1 exit status

root@krex:~/mysqludf/mysql-udf# uname -a
Linux xeon-01 2.6.20-15-generic #2 SMP Sun Apr 15 06:17:24 UTC
2007 x86_64 GNU/Linux

root@krex:~/mysqludf/mysql-udf# gcc -shared -fPIC -lstdc++ -I
/usr/include -I /usr/local/include -I /opt/lampp/include/ -I
/opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
root@krex:~/mysqludf/mysql-udf# ls
udf_colwidth.cc udf_correlation.cc udf_intercept.cc
udf_median.cc udf_skewness.cc udf_stdnorm_dist.cc
udf_confidence_higher.cc udf_faculty.cc udf_kurtosis.cc
udf_median.so udf_slope.cc udf_weightedavg.cc
udf_confidence_lower.cc udf_geomean.cc udf_longest.cc
udf_noverm.cc udf_stdnorm_density.cc

root@krex:~/mysqludf/mysql-udf# cp udf_median.so /usr/lib/

root@krex:~/mysqludf/mysql-udf# mysql -uroot –p test
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 84928
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> create aggregate function median returns real soname
'udf_median.so';
Query OK, 0 rows affected (0.04 sec)
mysql> select median(SalePrice) from DB.Table_Name;
+-------------------+
| median(SalePrice) |
+-------------------+
| 262000.00         |
+-------------------+
1 row in set (2.49 sec)



Voila…. Installation finished!!! Now it’s easy enough to obtain a median!

http://kedar.nitty-witty.com/blog/

More Related Content

Viewers also liked

PLAN DE ACCION PERU
PLAN DE ACCION PERUPLAN DE ACCION PERU
PLAN DE ACCION PERUenriquebio2
 
LeverX SAP ABAP Tutorial Creating Function Modules
LeverX SAP ABAP Tutorial Creating Function ModulesLeverX SAP ABAP Tutorial Creating Function Modules
LeverX SAP ABAP Tutorial Creating Function ModulesLeverX
 
Chromatic signs o mga sagisag kromatiko music 5 q2 wk3
Chromatic signs o  mga sagisag kromatiko music 5 q2 wk3Chromatic signs o  mga sagisag kromatiko music 5 q2 wk3
Chromatic signs o mga sagisag kromatiko music 5 q2 wk3Marissa Gillado
 
Mean, Median, Mode, And Range
Mean, Median, Mode, And RangeMean, Median, Mode, And Range
Mean, Median, Mode, And Rangetmathteacher86
 
Year in review: The Most Colourful and Spectacular Festivals of 2016
Year in review: The Most Colourful and Spectacular Festivals of 2016Year in review: The Most Colourful and Spectacular Festivals of 2016
Year in review: The Most Colourful and Spectacular Festivals of 2016maditabalnco
 
K TO 12 GRADE 3 LEARNING MATERIAL IN MUSIC
K TO 12 GRADE 3 LEARNING MATERIAL IN MUSICK TO 12 GRADE 3 LEARNING MATERIAL IN MUSIC
K TO 12 GRADE 3 LEARNING MATERIAL IN MUSICLiGhT ArOhL
 
Grade 3 Music Teachers Guide
Grade 3 Music Teachers GuideGrade 3 Music Teachers Guide
Grade 3 Music Teachers GuideLance Razon
 
K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)LiGhT ArOhL
 
Mean, median, mode, & range ppt
Mean, median, mode, & range pptMean, median, mode, & range ppt
Mean, median, mode, & range pptmashal2013
 
Festivals And Fiestas in the Philippines
Festivals And Fiestas in the PhilippinesFestivals And Fiestas in the Philippines
Festivals And Fiestas in the Philippinesmisskml
 
K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)LiGhT ArOhL
 
Sinaunang paniniwala at kaugalian
Sinaunang paniniwala at kaugalianSinaunang paniniwala at kaugalian
Sinaunang paniniwala at kaugalianHannah Dionela
 

Viewers also liked (16)

PLAN DE ACCION PERU
PLAN DE ACCION PERUPLAN DE ACCION PERU
PLAN DE ACCION PERU
 
Introduction to mysql part 4
Introduction to mysql part 4Introduction to mysql part 4
Introduction to mysql part 4
 
LeverX SAP ABAP Tutorial Creating Function Modules
LeverX SAP ABAP Tutorial Creating Function ModulesLeverX SAP ABAP Tutorial Creating Function Modules
LeverX SAP ABAP Tutorial Creating Function Modules
 
Chromatic signs o mga sagisag kromatiko music 5 q2 wk3
Chromatic signs o  mga sagisag kromatiko music 5 q2 wk3Chromatic signs o  mga sagisag kromatiko music 5 q2 wk3
Chromatic signs o mga sagisag kromatiko music 5 q2 wk3
 
Mean, Median, Mode, And Range
Mean, Median, Mode, And RangeMean, Median, Mode, And Range
Mean, Median, Mode, And Range
 
Year in review: The Most Colourful and Spectacular Festivals of 2016
Year in review: The Most Colourful and Spectacular Festivals of 2016Year in review: The Most Colourful and Spectacular Festivals of 2016
Year in review: The Most Colourful and Spectacular Festivals of 2016
 
K TO 12 GRADE 3 LEARNING MATERIAL IN MUSIC
K TO 12 GRADE 3 LEARNING MATERIAL IN MUSICK TO 12 GRADE 3 LEARNING MATERIAL IN MUSIC
K TO 12 GRADE 3 LEARNING MATERIAL IN MUSIC
 
Ano ang kultura
Ano ang kulturaAno ang kultura
Ano ang kultura
 
Grade 3 Music Teachers Guide
Grade 3 Music Teachers GuideGrade 3 Music Teachers Guide
Grade 3 Music Teachers Guide
 
K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 5 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
 
Philippine literature
Philippine literaturePhilippine literature
Philippine literature
 
Mean, median, mode, & range ppt
Mean, median, mode, & range pptMean, median, mode, & range ppt
Mean, median, mode, & range ppt
 
Festivals And Fiestas in the Philippines
Festivals And Fiestas in the PhilippinesFestivals And Fiestas in the Philippines
Festivals And Fiestas in the Philippines
 
K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
K TO 12 GRADE 4 LEARNER’S MATERIAL IN MUSIC (Q1-Q4)
 
Mapeh
MapehMapeh
Mapeh
 
Sinaunang paniniwala at kaugalian
Sinaunang paniniwala at kaugalianSinaunang paniniwala at kaugalian
Sinaunang paniniwala at kaugalian
 

Similar to Median-udf in mysql : Step By Step Installation And Problem Fixes For Installing My Sql Udf

CS301-lec01.ppt
CS301-lec01.pptCS301-lec01.ppt
CS301-lec01.pptomair31
 
20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdfMariaKhan905189
 
RUCK 2017 MxNet과 R을 연동한 딥러닝 소개
RUCK 2017 MxNet과 R을 연동한 딥러닝 소개RUCK 2017 MxNet과 R을 연동한 딥러닝 소개
RUCK 2017 MxNet과 R을 연동한 딥러닝 소개r-kor
 
Das20502 chapter 1 descriptive statistics
Das20502 chapter 1 descriptive statisticsDas20502 chapter 1 descriptive statistics
Das20502 chapter 1 descriptive statisticsRozainita Rosley
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1ecomputernotes
 
Sas basis imp intrw ques
Sas basis imp intrw quesSas basis imp intrw ques
Sas basis imp intrw quesVinod Kumar
 
Computer notes - data structures
Computer notes - data structuresComputer notes - data structures
Computer notes - data structuresecomputernotes
 
SASO2013 - PechaKucha version
SASO2013 - PechaKucha versionSASO2013 - PechaKucha version
SASO2013 - PechaKucha versionSandro Andrade
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Ashwini Mathur
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learningMax Kleiner
 
Next Generation Programming in R
Next Generation Programming in RNext Generation Programming in R
Next Generation Programming in RFlorian Uhlitz
 
Data structures cs301 power point slides lecture 01
Data structures   cs301 power point slides lecture 01Data structures   cs301 power point slides lecture 01
Data structures cs301 power point slides lecture 01shaziabibi5
 
Performing Data Science with HBase
Performing Data Science with HBasePerforming Data Science with HBase
Performing Data Science with HBaseWibiData
 
2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revised2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revisedKrish_ver2
 
Error based blind sqli
Error based blind sqliError based blind sqli
Error based blind sqliDarkZtone Zone
 

Similar to Median-udf in mysql : Step By Step Installation And Problem Fixes For Installing My Sql Udf (20)

CS301-lec01.ppt
CS301-lec01.pptCS301-lec01.ppt
CS301-lec01.ppt
 
20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf
 
Data Structure Lec #1
Data Structure Lec #1Data Structure Lec #1
Data Structure Lec #1
 
RUCK 2017 MxNet과 R을 연동한 딥러닝 소개
RUCK 2017 MxNet과 R을 연동한 딥러닝 소개RUCK 2017 MxNet과 R을 연동한 딥러닝 소개
RUCK 2017 MxNet과 R을 연동한 딥러닝 소개
 
Das20502 chapter 1 descriptive statistics
Das20502 chapter 1 descriptive statisticsDas20502 chapter 1 descriptive statistics
Das20502 chapter 1 descriptive statistics
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
 
Sas basis imp intrw ques
Sas basis imp intrw quesSas basis imp intrw ques
Sas basis imp intrw ques
 
Computer notes - data structures
Computer notes - data structuresComputer notes - data structures
Computer notes - data structures
 
MSE.pptx
MSE.pptxMSE.pptx
MSE.pptx
 
SASO2013 - PechaKucha version
SASO2013 - PechaKucha versionSASO2013 - PechaKucha version
SASO2013 - PechaKucha version
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
 
Data mining-2
Data mining-2Data mining-2
Data mining-2
 
Next Generation Programming in R
Next Generation Programming in RNext Generation Programming in R
Next Generation Programming in R
 
Data structures cs301 power point slides lecture 01
Data structures   cs301 power point slides lecture 01Data structures   cs301 power point slides lecture 01
Data structures cs301 power point slides lecture 01
 
Performing Data Science with HBase
Performing Data Science with HBasePerforming Data Science with HBase
Performing Data Science with HBase
 
2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revised2.6 support vector machines and associative classifiers revised
2.6 support vector machines and associative classifiers revised
 
DA_02_algorithms.pptx
DA_02_algorithms.pptxDA_02_algorithms.pptx
DA_02_algorithms.pptx
 
Leip103
Leip103Leip103
Leip103
 
Error based blind sqli
Error based blind sqliError based blind sqli
Error based blind sqli
 

Recently uploaded

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Median-udf in mysql : Step By Step Installation And Problem Fixes For Installing My Sql Udf

  • 1. My step by step installation and problem fixes of MySQL Statistical UDF – Median. Wikipedia: “In probability theory and statistics, a median is described as the numeric value separating the higher half of a sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one. If there is an even number of observations, then there is no single middle value, so one often takes the mean of the two middle values.” Approach for obtaining Median, the middle most value, earlier was as follows: Create a temporary table to obtain middle most value(s) and then take average of them. 1. CREATE TEMPORARY TABLE medians SELECT x.val FROM data x, data y GROUP BY x.val HAVING ((COUNT(*)-(SUM(SIGN(1-SIGN(y.val-x.val))))) <= floor((COUNT(*) +1)/2)) and ((COUNT(*)-(SUM(SIGN(1+SIGN(y.val-x.val))))) <= floor((COUNT(*) +1)/2)); 2. SELECT AVG(val) AS median FROM medians; [As suggested by Kreaseck.] But Median-UDF has brought us to ease in getting median value easily. Following is a kind of snap shot / steps I executed on my linux- ubuntu box to get the Median UDF working on MySQL 5.0. I faced approx 3 minor errors which I got resolved; they’re also included in steps. root@krex:~/mysqludf# wget http://www.mooreds.com/files/mysql-udf-patched.tar.gz root@krex:~/mysqludf# ls mysql-udf-patched.tar.gz root@krex:~/mysqludf# tar -xzf mysql-udf-patched.tar.gz root@krex:~/mysqludf# cd mysql-udf/ root@krex:~/mysqludf/mysql-udf# ls udf_colwidth.cc udf_correlation.cc udf_intercept.cc udf_median.cc udf_slope.cc udf_weightedavg.cc udf_confidence_higher.cc udf_faculty.cc udf_kurtosis.cc udf_noverm.cc udf_stdnorm_density.cc udf_confidence_lower.cc udf_geomean.cc udf_longest.cc udf_skewness.cc udf_stdnorm_dist.cc
  • 2. root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I /usr/include -I /usr/local/include -I /usr/local/mysql/include/ -o udf_median.so udf_median.cc udf_median.cc:31:23: error: my_global.h: No such file or directory udf_median.cc:32:20: error: my_sys.h: No such file or directory udf_median.cc:34:19: error: mysql.h: No such file or directory udf_median.cc:35:21: error: m_ctype.h: No such file or directory udf_median.cc:36:24: error: m_string.h: No such file or directory root@krex:~/mysqludf/mysql-udf# locate my_global.h /opt/lampp/include/mysql/my_global.h root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I /usr/include -I /usr/local/include -I /opt/lampp/include/ -I /opt/lampp/include/mysql/ -o udf_median.so udf_median.cc In file included from udf_median.cc:31: /opt/lampp/include/mysql/my_global.h:353:24: error: asm/atomic.h: No such file or directory root@krex:~/mysqludf/mysql-udf# locate atomic.h /opt/lampp/include/atomic.h root@krex:~/mysqludf/mysql-udf# mkdir /opt/lampp/include/asm root@krex:~/mysqludf/mysql-udf# cp /opt/lampp/include/atomic.h /opt/lampp/include/asm/ root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I /usr/include -I /usr/local/include -I /opt/lampp/include/ -I /opt/lampp/include/mysql/ -o udf_median.so udf_median.cc /usr/bin/ld: /tmp/ccimPFiX.o: relocation R_X86_64_32 against `compare_doubles(void const*, void const*)' can not be used when making a shared object; recompile with -fPIC /tmp/ccimPFiX.o: could not read symbols: Bad value collect2: ld returned 1 exit status root@krex:~/mysqludf/mysql-udf# uname -a Linux xeon-01 2.6.20-15-generic #2 SMP Sun Apr 15 06:17:24 UTC 2007 x86_64 GNU/Linux root@krex:~/mysqludf/mysql-udf# gcc -shared -fPIC -lstdc++ -I /usr/include -I /usr/local/include -I /opt/lampp/include/ -I /opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
  • 3. root@krex:~/mysqludf/mysql-udf# ls udf_colwidth.cc udf_correlation.cc udf_intercept.cc udf_median.cc udf_skewness.cc udf_stdnorm_dist.cc udf_confidence_higher.cc udf_faculty.cc udf_kurtosis.cc udf_median.so udf_slope.cc udf_weightedavg.cc udf_confidence_lower.cc udf_geomean.cc udf_longest.cc udf_noverm.cc udf_stdnorm_density.cc root@krex:~/mysqludf/mysql-udf# cp udf_median.so /usr/lib/ root@krex:~/mysqludf/mysql-udf# mysql -uroot –p test Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 84928 Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql> create aggregate function median returns real soname 'udf_median.so'; Query OK, 0 rows affected (0.04 sec) mysql> select median(SalePrice) from DB.Table_Name; +-------------------+ | median(SalePrice) | +-------------------+ | 262000.00 | +-------------------+ 1 row in set (2.49 sec) Voila…. Installation finished!!! Now it’s easy enough to obtain a median! http://kedar.nitty-witty.com/blog/