Convert Varchar to Double in SQL

George John
Updated on 30-Jul-2019 22:30:24

5K+ Views

You can convert varchar to double using CAST() function. The syntax is as follows:SELECT yourColumnName1, yourColumnName2, ......N, CAST(yourColumnName AS DECIMAL(TotalDigit, DigitAfterDecimalPoint)) anyVariableName FROM yourtableName ORDER BY anyVariableName DESC;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table VarcharToDouble    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(10),    -> Amount varchar(10) ,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into VarcharToDouble(Name, Amount) values('John', ... Read More

Remove a Value from Java LinkedHashMap

Samual Sam
Updated on 30-Jul-2019 22:30:24

2K+ Views

Use the remove() method to remove a single value from LinkedHashMap −At first, create a LinkedHashMap and add some elements −LinkedHashMap l = new LinkedHashMap(); l.put("1", "Jack"); l.put("2", "Tom"); l.put("3", "Jimmy"); l.put("4", "Morgan"); l.put("5", "Tim"); l.put("6", "Brad");Now, let’s say you need to remove the element 2 from the LinkedHashMap. For that, use the remove() method −Object ob = l.remove("2");The following is an example to remove a value from LinkedHashMap in Java −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { LinkedHashMap l = new LinkedHashMap(); ... Read More

Create NSIndexPath for UITableView in iOS

Chandu yadav
Updated on 30-Jul-2019 22:30:24

904 Views

Index path is generally a set of two values representing row and section of a table view. Index path can be created in objective C as well as Swift as both are native language of iOS Development.IndexPathForRow is a class method in iOS. To create a index path we need to be sure about the section and row we need to create. Below are the methods of creating an Indexpath.To create an IndexPath in objective C we can use.NSIndexPath *myIP = [NSIndexPath indexPathForRow: Int inSection:Int] ;ExampleNSIndexPath *myIP = [NSIndexPath indexPathForRow: 5 inSection: 2] ;To create an IndexPath in Swift we ... Read More

Fastest Ball in the History of Cricket

Vihan Rodrigues
Updated on 30-Jul-2019 22:30:24

564 Views

When we hear the fastest ball, the fierce faces of all fast bowlers and their tough looks start striking our mind. It includes Wasim Akram, Courtney Walsh, Chaminda Vaas, Umar Gul, etc. But the question still remains unanswered that who among the fast bowler fraternity has done this miracle.Well, the answer is Shoaib Akhtar who is recognized as the fastest bowler in the history of cricket by delivering an officially recorded top speed of 163.3 km/h in a pool match against England during the 2003 Cricket World Cup. Unfortunately, Akhtar did not get any wicket on the ball.Fastest Recorded Deliveries ... Read More

Default Access Level in Java

Jai Janardhan
Updated on 30-Jul-2019 22:30:24

647 Views

The default access level is available when no access level is specified. All the classes, data members, methods etc. which have the default access level can only be accessed inside the same package.A program that demonstrates the default access level in Java is given as follows:Example Live Democlass Employee {    int empno;    String name;    void insert(int e, String n) {       empno = e;       name = n;    }    void display() {       System.out.println("Employee Number: " + empno);       System.out.println("Name: " + name);    } } public class ... Read More

What is a Sonnet in English Literature

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

546 Views

A small lyric poem of fourteen lines is a sonnet. There are two types of Sonnets: the Italian (Petrarchan) and the English (Shakespearean).In the Italian form, There are two intrinsic divisions: the first part consists of 8 lines and the second part is of 6 lines, in all making 14 lines.Shakespearian SonnetsBut the same does not happen in Shakesperian sonnets. William Shakespeare, the ‘Bard of Avon’, is noted to have mastered at least 38 plays, 154 sonnets, two long narrative poems, and a few other verses. His popularity can be estimated by the following “He was naturally learned; he needed ... Read More

Retrieve the Last Entry in a TreeMap in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

2K+ Views

Use the lastEntry() method in TreeMap to retrieve the last entry.Create a TreeMap and add some elements −TreeMap m = new TreeMap(); m.put(1, "India"); m.put(2, "US"); m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada");Now, retrieve the last entry −m.lastEntry()The following is an example to retrieve last entry in the TreeMap −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       TreeMap m = new TreeMap();       m.put(1, "India");       m.put(2, "US");       m.put(3, "Australia");       m.put(4, "Netherlands");       m.put(5, "Canada");       for(Map.Entry e:m.entrySet()) ... Read More

Use of Import Statement in Java

Rishi Raj
Updated on 30-Jul-2019 22:30:24

4K+ Views

The import statement can be used to import an entire package or sometimes import certain classes and interfaces inside the package. The import statement is written before the class definition and after the package statement(if there is any). Also, the import statement is optional.A program that demonstrates this in Java is given as follows:Example Live Demoimport java.util.LinkedList; public class Demo {    public static void main(String[] args) {       LinkedList l = new LinkedList();       l.add("Apple");       l.add("Mango");       l.add("Cherry");       l.add("Orange");       l.add("Pear");       System.out.println("The ... Read More

Change Year of Dates in MySQL from 2020 to 2011

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

520 Views

You can change year of dates from 2020 to 2011 using SUBDATE() with INTERVAL of 9 year because there is a difference of 9 years between 2020 to 2011.The syntax is as follows:UPDATE yourTableName SET yourDateColumnName=SUBDATE(yourDateColumnName, INTERVAL 9 YEAR);To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ChangeYearFrom2020To2011    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> ExpiryDate date,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command. The query to insert ... Read More

Programmatically Restart an Android App

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

3K+ Views

There are some situations, we need to restart whole application programmatically. This example demonstrates how do I programmatically “restart” an Android app.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken a text view. When the user clicks on text view, it will restart the whole application.package com.example.andy.myapplication; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; ... Read More

Advertisements