Posts

Showing posts with the label SQL

How to convert milliseconds or seconds into date format in Presto?

Milliseconds: DATE_FORMAT(FROM_UNIXTIME(column_name /1000),'%Y-%m-%d') Seconds: DATE_FORMAT(FROM_UNIXTIME(column_name),'%Y-%m-%d') Please note that '/1000' should be added when it converts milliseconds to human-readable format.  We have the column " purchased_date_epoch " stored as numeric format. Let's say we want to convert the " purchased_date_epoch " column value " 1442287036 " to  human-readable  format.  SELECT purchased_date_epoch FROM table                               return: 144287036  SELECT DATE_FORMAT(FROM_UNIXTIME(purchased_date_epoch),'%Y-%m-%d %T) return: 2015-09-15 03:17:16                                          SELECT DATE_FORMAT(FROM_UNIXTIME(purchased_date_epoch),'%Y-%m-%d)    return: 2015-09-15            ...

Use Pascal Function to Get Approximate P-value of A/B Testing

Image
If you are looking for script that allows you to get approximate p-value for your A/B testing, this is the place for you. Or if you are looking for reference to calculate p-value and z-value due to the limited available maths methods in SQL, the python script can be translated in SQL user define function. 

Awesome online free sources for you to start learning SQL and prepare for the Oracle Certification Exam

According to Oracle website (Original link is here ), in order to get the Oracle Database Administrator Certified Associate Level, candidates have to pass one of the three exams: - Oracle Database 11g: SQL Fundamentals I (Exam #: 1Z0-051)  - Oracle Database 12c: SQL Fundamentals (Exam #: 1Z0-061) - Oracle Database SQL Expert (Exam #: 1Z0-047) And after you pass one of the three exams listed above, you have to pass Oracle Database 11g: Administration I (Exam #: 1Z0-052)  I chose  Oracle Database 11g: SQL Fundamentals I (Exam #: 1Z0-051)  as my goal during the first step of getting the certification. If you chose the training provided by Oracle, it would cost you a lot of money. So I am going to introduce some websites to save you $3000.  1. CBT Nuggets (  https://www.cbtnuggets.com/ )  This is the best site I found on Google after searching for half an hour. It asked you to put your credit card information when you open the 7-day free trail. Do...

Lessons I learned from SQL Interview

Image
So today I had a technical interview with a company in Seattle. It was my first technical interview after two months of job hunting in the west coast. I am writing this posts to remember what I made a mistake in SQL as people usually say we learn lessons from mistakes and failure.  First, About the rule that "GROUP BY function only allows you to SELECT two columns at a time".  Remark: This does NOT include the new column you generate by using COUNT!! Typical way you write a query with GROUP BY is like this: SELECT Column1, Column 2 FROM TableName GROUP BY Column1;  HOWEVER, if you want to COUNT something else besides Column 1 and Column 2, you can write: SELECT Column1, Column2, COUNT(Column3)  FROM TableName GROUP BY Column 1;  SQL will not generate the errors when you put the third elements "COUNT(Column3) before "FROM TableName GROUP BY Column1" because "COUNT(Column3)" is not considered as the third column in the "GROUP BY...