Question

In: Computer Science

The database for a pet supply company includes the following table, named tblCollar, that contains product...

The database for a pet supply company includes the following table, named tblCollar, that contains product data for pet collars. The ItemDesc and Color fields contain text. The ItemNum, Price, and Quantity fields contain numbers.

ItemNum

ItemDesc

Color

Price

Quantity

2358

leather studded collar

black

30.00

35

2693

leather collar

brown

25.00

25

3547

striped collar

red

20.00

75

3855

striped collar

blue

15.00

42

3764

striped collar

green

15.00

48

5782

solid collar

pink

12.00

36

5785

solid collar

red

12.00

10

5787

solid collar

blue

10.00

15

Which of the following clauses would allow a user to select the records for collars with a cost of between 10 and 20?

a.

WHERE Price >= @Price1 AND Price <= @Price2

b.

WHERE Price LIKE 10 AND Price LIKE 20

c.

WHERE Price <= 10 AND Price >= 20

d.

WHERE @Price1 < Query  < @Price2

Solutions

Expert Solution

Option a is correct answer

Reason:- In where clause the price is is checkd between @price1 and @price2. So, first weset the value in variable

and run the select statement to display . Check below code:-

CREATE TABLE tblCollar(itemno integer PRIMARY KEY, itemdes text,color text, price integer,quqntity integer);

/* insert record */
INSERT INTO tblCollar VALUES(2358,'lether studded collar','black',30.00,35);
INSERT INTO tblCollar VALUES(2693,'lether collar','brown',25.00,25);
INSERT INTO tblCollar VALUES(3547,'stripped collar','red',20.00,75);
INSERT INTO tblCollar VALUES(3855,'stripped collar','blue',15.00,42);
INSERT INTO tblCollar VALUES(3764,'stripped collar','green',15.00,48);
INSERT INTO tblCollar VALUES(5782,'solid collar','pink',12.00,36);
INSERT INTO tblCollar VALUES(5785,'solid collar','red',12.00,10);
INSERT INTO tblCollar VALUES(5787,'solid collar','blue',10.00,15);

SET @price1 = 10, @price2 = 20; /* set variable to 10 and 20*/
SELECT * FROM tblCollar WHERE price>=@price1 and price<=@price2; /* it will display record between price 10 and 20*/

Output:-

Reason for Incorrect Answer:-

b. WHERE Price LIKE 10 AND Price LIKE 20

Like operater is used in where clouse to search specific pattern . So it will not show record between price 10 and 20. It's incorrect .

see below code as record is zero.

SELECT * FROM tblCollar WHERE Price LIKE 10 AND Price LIKE 20;

Output:-

C. WHERE Price <= 10 AND Price >= 20

As according to above statement it will display record not in between 10 and 20. so, It's incorrect.

D. WHERE @Price1 < Query  < @Price2

The above query will not display record between 10 and 20 because if we use select price query at place of Query it will give error. So, It's incorrect.


Related Solutions

The following table belongs to a pet boarding company. Each pet that is kept has a...
The following table belongs to a pet boarding company. Each pet that is kept has a type (species) and weight, an owner and the information where it is kept (which pen). The fee depends on the pen. It also depends on the owner because owners can have special rates.    Pet_id Type Weight Pen Fee Owner_id O_name 2800 Cat 9.2 P02 20 11 Susan 1739 Cat 7.5 P01 25 28 Brett 9981 Dog 3.3 P02 30 29 Jason Identify the...
You have a table for a membership database that contains the following fields: MemberLastName,
You have a table for a membership database that contains the following fields: MemberLastName, MemberFirstName, Street, City, State, ZipCode, and InitiationFee. There are 75,000 records in the table. What indexes would you create for the table, and why would you create these indexes?
A college records the module registration information of their students in a database named College.mdb,which contains...
A college records the module registration information of their students in a database named College.mdb,which contains three tables,STUDENT,MODULE andMODULE_REG. A student may enroll in the same module as many times as they like. However, they can only enroll each module at most once in each semester. The design of the three tables are shown below: Table STUDENT Field Name Data Type Note SID Short Text primary key FirstName Short Text LastName Short Text Contact Short Text Gender Short Text “M”...
Following is an extract from the database of a construction company. The table shows the height...
Following is an extract from the database of a construction company. The table shows the height of walls in feet and the cost of raising them. The estimated simple linear regression equation is given as Ŷ = b0 + b1X. (Hint: Use Excel functions). Height (ft) Cost ($) 4 670 3 430 7 810 9 1100 6 790 8 880 5 760 11 1200 1) What is the value of the coefficient b1? A) 254.8371 B) 0.010697 C) -2.14625 D)...
Consider the following table that contains an economy’s aggregate demand (AD) and short run aggregate supply...
Consider the following table that contains an economy’s aggregate demand (AD) and short run aggregate supply (SAS) schedules. Price level AD ($billion) SAS ($billion) 100 1000 850 110 950 950 120 900 1050 130 850 1200 140 800 1250 A)State the short run macroeconomic equilibrium and explain why this is an equilibrium. If potential GDP for this economy is $1,050 billion, is there an inflationary or recessionary gap, and how large is it? B)   Say real GDP supplied falls by...
For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name,...
For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name, price, quantity) transaction(trans_id, cust_id, time_date) product_trans(product_id, trans_id) Identify the primary keys and foreign keys for the relations and specify at least two different types of integrity constraints that would be applicable for different relations given.
The following table contains approximate figures for gross domestic product (GDP) and the national debt in...
The following table contains approximate figures for gross domestic product (GDP) and the national debt in the United States for June 2001 and June 2010. The national debt represents the total amount of money owed by the federal government to holders of U.S. securities. All numbers are in trillions of dollars. GDP Total National Debt Debt Held by Debt Held Outside Fed. Govt. and Fed. Reserve (Trillions of Dollars) (Trillions of Dollars) Federal Government Foreign Ownership (External National Debt) U.S....
Design a class named Pet, which should have the following fields: Name – The name field...
Design a class named Pet, which should have the following fields: Name – The name field holds the name of a pet. Type – The type field holds the type of animal that is the pet. Example values are “Dog”, “Cat”, and “Bird”. Age – The age field holds the pet’s age. The Pet class should also have the following methods: setName – The setName method stores a value in the name field. setType – The setType method stores a...
The following table contains information of 11 years of quaterly sales for KYRYH product Year Q1...
The following table contains information of 11 years of quaterly sales for KYRYH product Year Q1 Q2 Q3 Q4 Total 2006 37000 31000 27500 33800 129300 2007 38500 31700 27000 35000 132200 2008 40000 33000 28400 36000 137400 2009 41320 33000 29300 35800 139420 2010 42600 35200 30300 38400 146500 2011 42000 33000 28500 39000 142500 2012 43000 37800 32300 40600 153700 2013 47000 37000 31200 40000 155200 2014 46000 39000 28000 40500 153500 2015 49000 42300 33500 44000 168800...
5. The public debt - ownership The following table contains approximate figures for gross domestic product...
5. The public debt - ownership The following table contains approximate figures for gross domestic product (GDP) and the national debt in the United States for June 2001 and June 2010. The national debt represents the total amount of money owed by the federal government to holders of U.S. securities. All numbers are in trillions of dollars. GDP Total National Debt Debt Held by Debt Held Outside Fed. Govt. and Fed. Reserve (Trillions of Dollars) (Trillions of Dollars) U.S. Government...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT