For this, use GROUP BY along with COUNT(*). Let us first create a table −mysql> create table DemoTable ( EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeGender varchar(40) ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(EmployeeGender) values('MALE'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(EmployeeGender) values('FEMALE'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(EmployeeGender) values('FEMALE'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(EmployeeGender) values('FEMALE'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(EmployeeGender) values('MALE'); Query ... Read More
This program is to find minimum absolute difference of the array given we have an array which have distinct element.To learn this concept better let’s rebrush the things that required, Array is a container of elements of same data type. The length of an array needs to be predefined.absolute difference is the absolute value of the difference between two numbers i.e. the difference will always be positive, negative values will be converted to positive.The sum of minimum absolute difference of each element has to be found the minimum absolute solute difference formula isMinimum Absolute Difference (a) = min(abs(a – arr[j])) ;where 1 ... Read More
Let us first create a table −mysql> create table DemoTable ( DueDate varchar(100) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('August 04, 2019'); Query OK, 1 row affected (0.25 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----------------+ | DueDate | +----------------+ | August 04, 2019 | +----------------+ 1 row in set (0.00 sec)Following is the query to format date −mysql> set @stringToDate=(select date_format(str_to_date(DueDate, '%M %d, %Y'), '%Y-%m-%d') from ... Read More
What are Integer Functions in C Library?Integer functions are those functions which returns the exact value of an integer. C only supports integer values. In this function the nearest integer which is less than or equal to the argument returns to this function.Types of Integer functions −int = abs (int n); long = labs (long n); long long = llabs (long long n);where n = integer valueWhat is abs(), labs(), llabs() functions ?They are defined as (C Standard General Utilities Library) header file. They give the exact value of integer that is input to them as their argument.abs() function ... Read More
You can truncate the table to set auto_increment value to start from 1 in MySQL. Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (1.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.06 sec)Display all records ... Read More
Array is a data structure that stores multiple elements of the same data type. It can store entire set of values at once. But its length needs to be defined beforehand.In this sum array puzzle, we are given an array A1 of a definite size say n. In order to solve this puzzle, we will create an array called S1 that stores the sum of all elements of the array except the element whose position is being used. For example, if S1[3] is being calculated then we will find the sum of all elements of A1 except the element at ... Read More
A program to shutdown the system works on the operating systems like windows, linux or macOS. To shut it off and close all opened applications.What shut down or power off means?Shut down or Power off a computer means removing power from a computer's main components in an organised prescribed way and turning off all the works that are done by the computer i.e. all applications and processings are shut off. After a computer is shut down, the main components such as CPU, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, ... Read More
No, ^ is the Bitwise XOR operator in MySQL. For this, use POW() or POWER() from MySQL. Let us first create a table &minuns;mysql> create table DemoTable ( BaseValue int, PowerValue float ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(4, 1.9867); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(10, 6.789); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(20, 8.9); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from ... Read More
Find the area of largest Triangle inscribed in a hexagon we need to learn these figures are and how 1 is inscribed inside other.Triangle is a closed figure with 3 sides which may be equal or different size.Hexagon is a closed figure with 6 sides which may be equal or unequal in size.A triangle inscribed inside a hexagon has all its vertices touching vertices of hexagon. So, the sides of the triangle can be treated as diagonals of a regular hexagon. The hexagon considered here is a regular hexagon, which leads to make the largest triangle an Equilateral triangle.Let’s derive ... Read More
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(20), ProductPrice int ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName, ProductPrice) values('Chris', 600); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(CustomerName, ProductPrice) values('David', 450); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(CustomerName, ProductPrice) values('Chris', 980); Query OK, 1 row affected (0.40 sec) mysql> insert into DemoTable(CustomerName, ProductPrice) values('Mike', 1200); Query OK, 1 row affected (0.11 sec) mysql> insert into ... Read More