Which query would give the required result?

Using the CUSTOMERS table, you need to generate a report that shows 50% of each credit amount
in each income level. The report should NOT show any repeated credit amounts in each income level.
Which query would give the required result?

Using the CUSTOMERS table, you need to generate a report that shows 50% of each credit amount
in each income level. The report should NOT show any repeated credit amounts in each income level.
Which query would give the required result?

A.
SELECT cust_income_level, DISTINCT cust_credit_limit * 0.50 AS "50% Credit Limit"
FROM customers;

B.
SELECT DISTINCT cust_income_level, DISTINCT cust_credit_limit * 0.50 AS "50% Credit Limit"
FROM customers;

C.
SELECT DISTINCT cust_income_level ‘ ‘ cust_credit_limit * 0.50 AS "50% Credit Limit"
FROM customers;

D.
SELECT cust_income_level ‘ ‘ cust_credit_limit * 0.50 AS "50% Credit Limit" FROM customers;



Leave a Reply 13

Your email address will not be published. Required fields are marked *


banu

banu

why Option A is not correct?

Justyna

Justyna

‘Distinct’ has to be placed just after word ‘select’ not somewhere in between column names.

Alex

Alex

I wasn’t aware you could use commas to select distinct values for multiple columns.

Banu

Banu

what is ” in C option

Justyna

Justyna

I think it should be there concatenation sign: ||

anshu

anshu

what is ” in C option ??

Eric Sacramento

Eric Sacramento

A and B – syntax error
D – there’s no distinct

innez

innez

what is ” in C option ??

id that for “to select distinct values for multiple columns” ????

Ritam Tiwari

Ritam Tiwari

actually i tried to execute this query and for this ‘ ‘ its showning invalid charcter.

Justyna

Justyna

Yes, in the query is missing concatenation sign ||. I will try to copy here complete statement:
SELECT DISTINCT cust_income_level||cust_credit_limit * 0.50 AS “50% Credit Limit”
FROM customers;

Soti

Soti

I think there is something wrong with the syntax of “C”, even if we use the concatenation operator.
While I do agree it executes successfully (with “||”), the output just does not make sense – see below. I think the double quaotation sign should be a comma, not a concatenation operator:

50% Credit Limit
———————————————————————-
B: 30,000 – 49,9991500
I: 170,000 – 189,9992500
H: 150,000 – 169,9993500
I: 170,000 – 189,9995500
D: 70,000 – 89,9994500
F: 110,000 – 129,999750
E: 90,000 – 109,9992500
J: 190,000 – 249,9997500
G: 130,000 – 149,999750
G: 130,000 – 149,9994500
K: 250,000 – 299,9993500
B: 30,000 – 49,999750
I: 170,000 – 189,9997500
G: 130,000 – 149,9995000
A: Below 30,0001500
L: 300,000 and above7500
H: 150,000 – 169,9995500
I: 170,000 – 189,999750
I: 170,000 – 189,9994500
G: 130,000 – 149,9992500
C: 50,000 – 69,9993500

Soti

Soti

Just found the correct script for “C”. It should be:

SELECT DISTINCT cust_income_level || ‘ ‘ || cust_credit_limit * 0.50 AS “50% Credit Limit”
FROM customers;

mariusftc

mariusftc

Actually …it strikes me that C option is very logical !

select 300||’abracadabra’||1000*.5 from dual; => 300abracadabra500 (string)

If this string value appears more then one(1) time, then DISTINCT clause will take care of it(eliminate duplicates)!

The rest is just a detail (each credit amount in each income level means selecting first cust_income_level and second cust_credit_limit as arguments )