Posts

Showing posts from September, 2017

SQL

                                                               SQL Short notes:- 1.get Today Records:  TO_CHAR(CREATE_STP, 'MM-DD-YYYY')=TO_CHAR(SYSDATE, 'MM-DD-YYYY') 2.Get UUDID: select sys_guid() from dual; 3.UUID to string : UPPER(REPLACE('5379efd7-cc4b-6fda-e053-2c97f4a10fdb','-')); 1.Second highest salary emp records select * from emp where sal=(select max(sal) from emp where sal<(select max(sal) from emp)) 2.Nth highest salary? 3.HAVING clause :- https://www.techonthenet.com/oracle/having.php SELECT exp1, exp2, ... expression_n, aggregate_function (aggregate_expression) FROM tables [WHERE conditions] GROUP BY expr1, exp2, ... expression_n HAVING having_condition; Ex:- SELECT department, SUM(sales) AS "Total sales" FROM order_details GROUP BY department HAVING SUM(sales) > 25000; 4.Optimize queries based on the query optimization guidelines Follow the SQL best practices to ensure query optimization: 1. Index

For Loop Performance Test

import java.util.ArrayList; import java.util.Calendar; import java.util.List; public class ForLoopPerformanceTest{     private static List<Integer> list = new ArrayList<Integer>();     private static long          startTime;     public static void main(String[] args) {         for (int i = 0; i < 10000000; i++) {             list.add(i);         }         // Java 8 for each         startTime = Calendar.getInstance().getTimeInMillis();         list.forEach(e -> {  });         System.out  .println("Using java 8 for each :: " +         (Calendar.getInstance().getTimeInMillis() - startTime) + " ms");         // Type 1         startTime = Calendar.getInstance().getTimeInMillis();         for (Integer i : list) {      //   }         System.out.println("Using For each loop :: " +        (Calendar.getInstance().getTimeInMillis() - startTime) + " ms");         // Type 2         startTime = Calendar.getInstance().