Krantik Chavan has Published 308 Articles

Can I use SUM() with IF() in MySQL?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

185 Views

Yes, you can use SUM() with IF() in MySQL. Let us first create a demo table:mysql> create table DemoTable (    Value int,    Value2 int ); Query OK, 0 rows affected (0.51 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable ... Read More

Can we use backticks with column value in MySQL?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

173 Views

You cannot use backticks with column value. For this, use only table name or column name. If you use backtick with column value then MySQL will give the following error message:ERROR 1054 (42S22): Unknown column '191.23.41.10' in 'where clause'Let us first create a table:mysql> create table DemoTable6 (    SystemIPAddress ... Read More

DoubleStream forEach() method in Java

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

98 Views

The forEach() method of the DoubleStream class performs an action for each element of this stream.The syntax is as follows:void forEach(DoubleConsumer action)Here, DoubleConsumer represents an operation that accepts a single double-valued argument and returns no result. The parameter action is a non-interfering action to perform on the elements.To use the ... Read More

ArrayBlockingQueue put() method in Java

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

79 Views

The put() method of the ArrayBlockingQueue class inserts the specified element at the tail of this queue. It waits for the space to become available, if the queue is full.The syntax is as follows:void put(E e)Here, e is the element to be inserted.To work with ArrayBlockingQueue class, you need to ... Read More

How to multiply columns and then sum the rows with similar records like customer name?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

110 Views

To understand this, let us create a table with fields like ID, Customer Name, Items, Price. We will first multiply the items with price. After that the rows with similar records i.e. same customer name will get added.Let us first create a table:mysql> create table DemoTable (    CustomerId int ... Read More

Create Octet Tuple from an array in Java

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

94 Views

To create Octet Tuple from an array in Java, use the fromArray() method. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package:import org.javatuples.Octet;Note: Download JavaTuples Jar library to run JavaTuples program. If you are ... Read More

Get count of values that only appear once in a MySQL column?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

447 Views

To get number of values that only appear once in a column, use GROUP BY HAVING. Let us first create a table:mysql> create table DemoTable (    Name varchar(20) ); Query OK, 0 rows affected (0.55 sec)Following is the query to insert some records in the table using insert command:mysql> ... Read More

DoubleStream average() method in Java

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

1K+ Views

The average() method of the DoubleStream class in Java returns an OptionalDouble which is the arithmetic mean of elements of this stream. If the stream is empty, empty is returned.The syntax is as follows:OptionalDouble average()Here, OptionalDouble is a container object which may or may not contain a double value.To use ... Read More

How can I get maximum and minimum values in a single MySQL query?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

109 Views

To get maximum and minimum values in a single query, use the aggregate function min() and max(). Let us first create a table:mysql> create table DemoTable (    FirstValue int,    SecondValue int ); Query OK, 0 rows affected (0.66 sec)Following is the query to insert some records in the ... Read More

Create KeyValue Tuple from a List collection in Java

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

78 Views

To create KeyValue tuple from List collection, use the fromCollection() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse ... Read More

Advertisements