1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AlexFokin [52]
3 years ago
10

A blood bank maintains two tables - DONOR, with information about people who are willing to donate blood and ACCEPTOR, with info

rmation about the people who are in need of blood. The bank wants to know the number of males and the number of females with a particular blood group.
In the Output: each row must contain gender, BG and count of people with that CG and GENDER.

Table Schemas:

DONOR

Name -- Type -- Desc

DID int Donor ID
NAME VARCHAR Name of Donor
BG VARCHAR BLOOD GROUP
GENDER VARCHAR Gender
ACCEPTOR

Name -- Type -- Desc

AID int Acceptor ID
NAME VARCHAR Name of Acceptor
BG VARCHAR BLOOD GROUP
GENDER VARCHAR Gender
Computers and Technology
1 answer:
Kipish [7]3 years ago
7 0

Answer:

The sql query is given below.

Since we need to count of males and females for a particular blood group, we put xxx for the blood group.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors,

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

Explanation:

The clauses in the query are as follows.

1. SELECT: all the columns required in the output are put in this clause.

2. FROM JOIN ON: the table(s) from which the above columns are taken are put in this clause.

3. WHERE: any condition required to filter the output is put in this clause.

The query is explained below.

1. Find the number of male donors. Number of anything can be found using COUNT() function. A query is required since gender is included in deciding the type of donor.

2. The query is defined to find number of male donors as follows.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "M%"; )

3. In the previous query, LIKE operator is used since it is not defined what value is stored for male donors.

4. Similarly, the query to find the number of female donors is formed.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "F%"; )

5. Next, the final query is formed as follows.

SELECT: both COUNT() functions will come here.

FROM: table name

WHERE: specific blood group will be put here

GROUP BY: this clause is optional and is not used in this query.

HAVING: this clause is optional and is not used in this query.

6. The query after putting all clauses is shown below.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%"),

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%")

FROM DONOR

WHERE BG = xxx;

7. Alias is used in the above query for each column to get the final query.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors, COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

You might be interested in
Which solution eliminates the need for dedicated high-speed WAN connections between sites
s344n2d4d5 [400]

Answer:

running in the 90 s intensifies

Explanation:

4 0
2 years ago
Decrypt this secret message if your able to a lot will come..
nata0808 [166]

Answer:-

Failure

and 0008

Hope This Helps

7 0
2 years ago
Read 2 more answers
Define the computer with its workintg principple
GenaCL600 [577]

Explanation:

Computer is an electronic device that is designed to work with information.

WORKING PRINCIPLE OF COMPUTER

a.It accepts data and instructions by way of input,

b.It stores data,

c.It can process data as required by the user,

d.It gives result in the form of output,

e.It controls all operations inside a computer.

I hope it will help you

5 0
2 years ago
What translates binary data into images on a monitor?
g100num [7]
A video card is what allows a computer to translate the binary data into images.
8 0
3 years ago
The short-range two-way communication technology behind contactless payments is called ____.
sasho [114]
Near field communication
4 0
1 year ago
Other questions:
  • What is ment by creative middle way solution
    6·1 answer
  • Which is faster, a hi-speed usb port or a superspeed usb port?
    15·2 answers
  • You are the network administrator for a school system. Your boss informs you that she is thinking of implementing a BYOD program
    15·2 answers
  • List the gcc command-line options for each of the following: Generate a .o file rather than an executable. Generate a .s (assemb
    6·1 answer
  • Beth would like to run an nmap scan against all of the systems on her organization's private network. These include systems in t
    15·1 answer
  • An internet connection is required to access which type of software?
    5·1 answer
  • What did do you do if you made a mistake on a computer?
    14·2 answers
  • Identify the following​
    9·1 answer
  • PA theme is a major message that a writer convoys through a text. you have explored many themes in the hobbit one theme in the n
    5·1 answer
  • The field of ____ is concerned with the technical issues involved in information display. computer science
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!