Chandu yadav has Published 1163 Articles

Can we exclude entries with “0” while using MySQL AVG function?

Chandu yadav

Chandu yadav

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

4K+ Views

To exclude entries with “0”, you need to use NULLIF() with function AVG().The syntax is as followsSELECT AVG(NULLIF(yourColumnName, 0)) AS anyAliasName FROM yourTableName;Let us first create a tablemysql> create table AverageDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > StudentName varchar(20), ... Read More

Generate Infinite Stream of Double in Java using DoubleStream.iterate()

Chandu yadav

Chandu yadav

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

65 Views

The DoubleStream.iterate() returns an infinite sequential ordered DoubleStream produced by iterative application of a function f to an initial element seed, producing a Stream consisting of seed.The syntax is as followsstatic DoubleStream iterate(double seed, DoubleUnaryOperator f)Here, seed is the initial element and f is a function to be applied to ... Read More

Is it possible to enforce data checking in MySQL using Regular Expression?

Chandu yadav

Chandu yadav

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

277 Views

Yes, it is possible to enforce data checking in MySQL using regular expression. First, you need to create a table. After that you need to create a trigger before insert in table. Here, we will be checking the Phone Number format.The query to create a table is as followsmysql> create ... Read More

ArrayBlockingQueue clear() Method in Java

Chandu yadav

Chandu yadav

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

79 Views

The clear() method of the ArrayBlockingQueue class in Java is used to remove all the elements from this queue.The syntax is as followspublic void clear()To work with ArrayBlockingQueue class, you need to import the following packageimport java.util.concurrent.ArrayBlockingQueue;The following is an example to implement clear() method of Java ArrayBlockingQueue classExample Live Demoimport ... Read More

Drop all indexes from all the collections in a MongoDB database using the command line?

Chandu yadav

Chandu yadav

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

190 Views

Following is the syntax to drop all indexes from all collections in a MongoDB database using command linedb.getCollectionNames().forEach(function(yourVariableName) {    db.runCommand({dropIndexes: yourVariableName, index: "*"}); });The above syntax will drop all indexes except _id.Let us check the current database. Following is the query> dbThis will produce the following outputTestFollowing is the ... Read More

C++ Program to Implement Max Heap

Chandu yadav

Chandu yadav

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

12K+ Views

A Binary Heap is a complete binary tree which is either Min Heap or Max Heap. In a Max Binary Heap, the key at root must be maximum among all keys present in Binary Heap. This property must be recursively true for all nodes in Binary Tree. Min Binary Heap ... Read More

Access objects from the nested objects structure in MongoDB

Chandu yadav

Chandu yadav

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

606 Views

Access objects using dot notation. Let us first create a collection with documents> db.nestedObjectDemo.insertOne({"Student" : { "StudentDetails" : { "StudentPersonalDetails" : { "StudentName" : [ "John" ], ... "StudentCountryName" : [ "US" ], ... "StudentCoreSubject" : [ "C", "Java" ], ... "StudentProject" : [ "Online Book Store", "Pig Dice Game" ... Read More

Get only the file extension from a column with file names as strings in MySQL?

Chandu yadav

Chandu yadav

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

848 Views

For this, use the substring_index() function.The syntax is as followsselect substring_index(yourColumnName, '. ', -1) AS anyAliasNamefrom yourTableName;Let us first create a table. The query to create a table is as followsmysql> create table AllFiles - > ( - > Id int NOT NULL AUTO_INCREMENT ... Read More

How to get default phone Network operator name in android?

Chandu yadav

Chandu yadav

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

1K+ Views

This example demonstrate about How to get default phone Network operator name in android.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.     ... Read More

Query MongoDB with length criteria?

Chandu yadav

Chandu yadav

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

120 Views

To query MongoDB with length criteria, you can use regex. Following is the syntaxdb.yourCollectionName.find({ ‘yourFieldName’: { $regex: /^.{yourLengthValue1, yourLengthValue2}$/ } });Let us create a collection with documents. Following is the query> db.queryLengthDemo.insertOne({"StudentFullName":"John Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9a01ae353decbc2fc927c0") } > db.queryLengthDemo.insertOne({"StudentFullName":"John Doe"}); {    "acknowledged" : ... Read More

Advertisements