Tuesday, December 2, 2014

get percentages on SQL querry - Oracle

If we want to get the percentage of some column on same query, we can do it using "ratio_to_report() over()" function.
ratio_to_report(Number_of_books) over()
let's say we have following table called tbl_books.

Book Number_of_books
Book1 30
Book1 20
Book1 10

if we want to get percentages of each book over total number of books we can do as following,
select book,ratio_to_report(Number_of_books) over() * 100 as percentage from tbl_books
it gives,

Book percentage
Book1 50
Book1 33.333333333
Book1 16.66666666


Tuesday, October 7, 2014

Where does MySQL store data in PC


Windows

Find the my.ini file which store in the MySQL installation folder.
and then open the file and Find the “datadir”, this is the where does MySQL stored the data in Windows.
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"

Linux

Find the my.cnf with the sudo find / -name my.cnf command.
2) viewthe my.cnf file cat /etc/mysql/my.cnf
yongmo@myserver:~$ cat /etc/mysql/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
[mysqld]
#
# * Basic Settings
#
user   = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket  = /var/run/mysqld/mysqld.sock
port   = 3306
basedir  = /usr
datadir  = /var/lib/mysql
tmpdir  = /tmp
language = /usr/share/mysql/english
skip-external-locking

3) Find the “datadir”, this is where does MySQL stored the data in Linux system.