Multiply Columns and Sum Rows with Similar Records Like Customer Name

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

230 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 NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerName varchar(100),    CustomerItems int,    CustomerPrice int ); Query OK, 0 rows affected (0.54 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable(CustomerName, CustomerItems, CustomerPrice)values('Larry', 3, 450); Query OK, 1 row affected (0.24 sec) mysql> ... Read More

Create Temporary File with Specified Extension Suffix in Java

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

1K+ Views

A temporary file with the specified extension suffix can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) throws Exception {       File file = File.createTempFile("temp", ".java");       System.out.println(file.getAbsolutePath());       file.deleteOnExit();      } }The output of the above program is as follows ... Read More

System Design Using Microcontroller

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

2K+ Views

Microprocessors and microcontrollers can be used to design some tools or systems to perform some special tasks. Using microcontrollers, we can make different types of modules or systems. Here is a list of some systems that can be designed by using microcontrollers −Electronic Voting MachineRFID based Access Control SystemHeart Rate monitoring systemAutomatic Plant watering systemUltrasonic range finding systemWater level controlling systemGas leakage detection systemFrequency MetersTemperature measuring systemThere are many such systems that can be made by using some microcontrollers.To design a system, we have to follow some basic steps. We have to design the overview of the system, and some ... Read More

Overloading Stream Insertion and Extraction Operators in C++

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

10K+ Views

C++ is able to input and output the built-in data types using the stream extraction operator >> and the stream insertion operator and insertion operator

Get the Last N Records in MongoDB

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

1K+ Views

To get the last N records in MongoDB, you need to use limit(). The syntax is as follows:db.yourCollectionName.find().sort({$natural:-1}).limit(yourValue);To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:> db.getLastNRecordsDemo.insertOne({"EmployeeName":"Maxwell"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf3d6fd07954a4890689") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf496fd07954a489068a") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Bob"}); { "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf4e6fd07954a489068b") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf546fd07954a489068c") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Robert"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf596fd07954a489068d") } > db.getLastNRecordsDemo.insertOne({"EmployeeName":"Mike"}); ... Read More

Working Example of Session Maintenance in JSP

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

331 Views

This example describes how to use the HttpSession object to find out the creation time and the last-accessed time for a session. We would associate a new session with the request if one does not already exist.           Session Tracking                   Session Tracking                         Session info          Value     ... Read More

Get Particular Date Records from Timestamp in Android SQLite

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

743 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to get particular date records from time stamp in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill ... Read More

period plusMonths Method in Java

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

169 Views

An immutable copy of the Period object where some months are added to it can be obtained using the plusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the Period object with the added months.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P5Y7M15D";       Period p1 = Period.parse(period);       System.out.println("The Period is: " + p1);       Period p2 ... Read More

LocalDateTime getYear Method in Java

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

694 Views

The year for a particular LocalDateTime can be obtained using the getYear() method in the LocalDateTime class in Java. This method requires no parameters and it returns the year which can range from MIN_YEAR to MAX_YEAR.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDateTime ldt = LocalDateTime.parse("2019-02-18T15:28:35");       System.out.println("The LocalDateTime is: " + ldt);       System.out.println("The year is: " + ldt.getYear());    } }OutputThe LocalDateTime is: 2019-02-18T15:28:35 The year is: 2019Now let us understand the above program.First the ... Read More

See Spaces in Data with MySQL Command Line Client

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

227 Views

Use quote() function for this. The syntax is as follows −select yourColumnName, quote(yourColumnName) from yourTableName;To understand the concept, let us create a table. The query to create a table is as follows −mysql> create table seeSpacesDemo    -> (    -> spaceValue varchar(10)    -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into seeSpacesDemo values(""); Query OK, 1 row affected (0.70 sec) mysql> insert into seeSpacesDemo values(" "); Query OK, 1 row affected (0.45 sec) mysql> insert into seeSpacesDemo values(" "); Query OK, 1 ... Read More

Advertisements