In mysql we will show how to get 50% record of employee table , given below example step by step.

Step : 1 – Create Database

CREATE DATABASE educationidol;

Step : 2 – Create Table

CREATE TABLE employee (
id int(11) DEFAULT NULL,
name varchar(40) DEFAULT NULL,
salary int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Step : 3 – Insert record in employee table

INSERT INTO employee (id, name, salary) VALUES
(1, ‘Mike’, 3000),
(2, ‘John’, 4000),
(3, ‘Shane’, 3000),
(4, ‘Biden’, 5000),
(5, ‘Shane’, 3000),
(6, ‘Biden’, 5000),
(7, ‘Shane’, 3000),
(8, ‘Bravo’, 7000);

Step : 4

Below is define the query so we can find to 50% record of table using mysql query.

SELECT * FROM employee WHERE id <= (SELECT COUNT(id)/2 from employee)

Related Topic :
Physics FormulasChemistry Formulas
Maths FormulasComputer Interview Questions and Answers for Freshers & Experienced
What is LibreOffice? LibreOffice Impress Features ?LibreOffice Impress CCC Questions and Answer in Hindi 2022
CCC LibreOffice Calc Paper Questions with AnswersCCC NIELIT Quiz 2022
Interview Questions and Answers for ExperienceInterview Questions and Answers for Freshers
MCQ 
[social_share_button themes='theme1']

Leave a Comment