FliQi Education App Download
प्रश्न-बैंक · DBMS

Single Row Functions — प्रश्न और उत्तर

DBMS · 25 जाँचे हुए (verified) प्रश्न

  • 25 जाँचे हुए प्रश्न
  • हिंदी + English

पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 15 के उत्तर और हल FliQi Question Bank app में।

भाषा
प्रश्न 1उत्तर + हल
निम्नलिखित query कौन-सी तिथि लौटाएगी?
SELECT ADD_MONTHS(TO_DATE('31-01-2026', 'DD-MM-YYYY'), 1) FROM DUAL;
Which date will the following query return?
SELECT ADD_MONTHS(TO_DATE('31-01-2026', 'DD-MM-YYYY'), 1) FROM DUAL;
  1. A28-02-2026
  2. B31-02-2026
  3. C03-03-2026
  4. D01-03-2026

सही उत्तर / Answer: (A)

हल / Solution
ADD_MONTHS महीना बढ़ाता है, दिन नहीं गिनता। नियम यह है कि दी गई तिथि महीने का अंतिम दिन हो, या अगले महीने में उतने दिन ही न हों, तो परिणाम उस महीने का अंतिम दिन बनता है। यहाँ तिथि जनवरी का अंतिम दिन है और वर्ष साधारण है, इसलिए परिणाम फरवरी का अट्ठाईसवाँ दिन है। इकतीस फरवरी कोई तिथि ही नहीं होती, और तीन मार्च इकतीस दिन जोड़ देने की भूल से आता है।
ADD_MONTHS moves the month forward and does not count days. Its rule is that when the given date is the last day of its month, or when the target month simply has fewer days, the result becomes the last day of that target month. The date here is the last day of January in an ordinary year, so the result is the twenty-eighth of February. A thirty-first of February is not a valid date at all.
प्रश्न 2उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT RPAD(LPAD('7', 3, '0'), 5, '*') FROM DUAL;
What will be the result of the following query?
SELECT RPAD(LPAD('7', 3, '0'), 5, '*') FROM DUAL;
  1. A007**
  2. B**007
  3. C00700
  4. D7****

सही उत्तर / Answer: (A)

हल / Solution
भीतर वाला LPAD पहले चलता है। वह मान को बाईं ओर से भरकर तीन अक्षर लंबा बनाता है, इसलिए एक अंक के आगे दो शून्य लग जाते हैं। इस तीन अक्षर वाले परिणाम पर अब RPAD लगता है, जो दाईं ओर से भरकर लंबाई पाँच करता है, इसलिए पीछे दो तारे जुड़ते हैं। **007 गलत है, क्योंकि RPAD दाईं ओर भरता है, बाईं ओर नहीं, और 7**** तब मिलता जब भीतर वाला LPAD छोड़ दिया जाता।
The inner LPAD runs first. It fills the value from the left until it is three characters long, so two zeros appear before the single digit. RPAD is then applied to that three character result, filling from the right until the length becomes five, which adds two stars at the end. The answer **007 is wrong because RPAD pads on the right and not on the left, while 7**** forgets the inner LPAD altogether.
प्रश्न 3उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT INSTR('DATABASE', 'A', 3, 2) FROM DUAL;
What will be the result of the following query?
SELECT INSTR('DATABASE', 'A', 3, 2) FROM DUAL;
  1. A2
  2. B4
  3. C6
  4. D0

सही उत्तर / Answer: (C)

हल / Solution
INSTR के चार argument का अर्थ है: किस मान में खोजें, क्या खोजें, कहाँ से खोजना शुरू करें और कौन-सी बार मिली जगह चाहिए। इस मान में खोजा जा रहा अक्षर दूसरी, चौथी और छठी जगह पर है। खोज तीसरी जगह से शुरू होती है, इसलिए दूसरी जगह गिनती में ही नहीं आती। अब पहली बार चौथी जगह मिलती है और दूसरी बार छठी, और हमें दूसरी बार चाहिए।
The four arguments of INSTR mean: the value to search in, what to search for, where to start searching and which occurrence is wanted. The searched letter sits at positions two, four and six in this value. The search starts at position three, so position two is never considered at all. The first occurrence from there is position four and the second is position six, and the second occurrence is the one requested.
प्रश्न 4उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT SUBSTR('DATABASE', -4, 3) FROM DUAL;
What will be the result of the following query?
SELECT SUBSTR('DATABASE', -4, 3) FROM DUAL;
  1. AABA
  2. BBAS
  3. CASE
  4. DDAT

सही उत्तर / Answer: (B)

हल / Solution
SUBSTR में शुरुआती जगह ऋणात्मक हो तो गिनती मान के अंत से पीछे की ओर होती है, पर अक्षर उठाए आगे की ओर ही जाते हैं। आठ अक्षरों वाले इस मान में अंत से चौथा अक्षर पाँचवीं जगह पर है, जो B है। वहाँ से तीन अक्षर लेने पर B, A और S मिलते हैं। ASE तब आता जब शुरुआत ऋण तीन से होती, DAT शुरू से गिनने पर मिलता, और ABA पीछे की ओर पढ़ने की भूल है।
When the starting position in SUBSTR is negative, counting runs backwards from the end of the value, but the characters are still picked moving forward. In this eight character value the fourth position from the end is the fifth character, which is B, and taking three characters from there gives B, A and S. ASE would need a start of minus three, DAT would come from counting forward, and ABA from reading backwards.
प्रश्न 5उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT INITCAP('data-BASE system') FROM DUAL;
What will be the result of the following query?
SELECT INITCAP('data-BASE system') FROM DUAL;
  1. AData-base system
  2. BData-Base System
  3. CData-BASE System
  4. DDATA-BASE SYSTEM

सही उत्तर / Answer: (B)

हल / Solution
INITCAP हर शब्द का पहला अक्षर बड़ा और बाक़ी अक्षर छोटे कर देता है। असली बात यह है कि शब्द की सीमा केवल space से नहीं बनती, बल्कि हर उस अक्षर से बनती है जो अक्षर या अंक नहीं है। यहाँ बीच का योजक चिह्न भी सीमा है, इसलिए उसके बाद का हिस्सा नया शब्द गिना जाता है और उसका पहला अक्षर भी बड़ा होता है। बड़े अक्षरों वाला हिस्सा छोटा कर दिया जाता है।
INITCAP makes the first letter of every word capital and forces the remaining letters to small letters. The real point is that a word boundary is not formed by a space alone but by any character that is neither a letter nor a digit. The hyphen in the middle is such a boundary, so the part after it counts as a fresh word and its first letter is capitalised too, while the shouted part is lowered.
प्रश्न 6उत्तर + हल
निम्नलिखित query कौन-सी तिथि लौटाएगी?
SELECT LAST_DAY(TO_DATE('14-02-2024', 'DD-MM-YYYY')) FROM DUAL;
Which date will the following query return?
SELECT LAST_DAY(TO_DATE('14-02-2024', 'DD-MM-YYYY')) FROM DUAL;
  1. A28-02-2024
  2. B29-02-2024
  3. C01-03-2024
  4. D14-03-2024

सही उत्तर / Answer: (B)

हल / Solution
LAST_DAY उसी महीने का अंतिम दिन लौटाता है जिसमें दी गई तिथि पड़ती है, और दिन की गिनती से इसका कोई लेना-देना नहीं। यहाँ महीना फरवरी है और वर्ष चार से पूरा-पूरा विभाजित होने वाला अधिवर्ष है, इसलिए फरवरी उनतीस दिन की होती है और वही अंतिम दिन लौटता है। अट्ठाईस साधारण वर्ष में सही होता। अगले महीने की पहली तारीख़ भी नहीं आती, क्योंकि LAST_DAY महीना बदलता नहीं।
LAST_DAY returns the final day of the very month in which the given date falls, and the day part of the input has no effect on it. The month here is February of a leap year, so February has twenty-nine days and that date is returned. The twenty-eighth would be correct in an ordinary year. The first day of the next month is wrong too, because LAST_DAY never moves into a different month.
प्रश्न 7उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT MONTHS_BETWEEN(TO_DATE('01-07-2026', 'DD-MM-YYYY'), TO_DATE('01-01-2026', 'DD-MM-YYYY')) FROM DUAL;
What will be the result of the following query?
SELECT MONTHS_BETWEEN(TO_DATE('01-07-2026', 'DD-MM-YYYY'), TO_DATE('01-01-2026', 'DD-MM-YYYY')) FROM DUAL;
  1. A6
  2. B-6
  3. C7
  4. D180

सही उत्तर / Answer: (A)

हल / Solution
MONTHS_BETWEEN पहले argument में से दूसरे को घटाकर महीनों की संख्या देता है। यहाँ पहली तिथि जुलाई की और दूसरी जनवरी की है, दोनों के दिन एक समान हैं, इसलिए उत्तर पूरा पूर्णांक छह आता है। ऋणात्मक छह तब मिलता जब दोनों तिथियाँ उलटे क्रम में लिखी जातीं, क्योंकि यहाँ क्रम मायने रखता है। एक सौ अस्सी गलत है, क्योंकि यह function महीने गिनता है, दिन नहीं।
MONTHS_BETWEEN subtracts the second argument from the first and reports the number of months. The first date lies in July and the second in January, and both fall on the same day of the month, so the answer is the whole number six. Minus six would result if the two dates were written in the opposite order, because the order matters. One hundred eighty is wrong, since the function counts months and not days.
प्रश्न 8उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT CASE 3 WHEN 1 THEN 'LOW' WHEN 2 THEN 'MID' ELSE 'HIGH' END FROM DUAL;
What will be the result of the following query?
SELECT CASE 3 WHEN 1 THEN 'LOW' WHEN 2 THEN 'MID' ELSE 'HIGH' END FROM DUAL;
  1. ALOW
  2. BMID
  3. CHIGH
  4. DNULL

सही उत्तर / Answer: (C)

हल / Solution
CASE के इस रूप में शुरू वाले मान की तुलना हर WHEN से क्रम से होती है। यहाँ न पहला WHEN मेल खाता है और न दूसरा, इसलिए नियंत्रण ELSE तक पहुँचता है और उसी का परिणाम लौटता है। LOW या MID तभी मिलते जब शुरू वाला मान एक या दो होता। NULL भी नहीं आता, क्योंकि ELSE लिखा हुआ है; ELSE छोड़ देने पर ही मेल न मिलने पर NULL लौटता है।
In this form of CASE the leading value is compared with each WHEN clause in order. Neither the first nor the second WHEN matches the value three, so control reaches the ELSE clause and its result is returned. LOW or MID would be produced only if the leading value had been one or two. NULL does not appear because an ELSE clause is present; NULL is returned on no match only when ELSE is omitted.
प्रश्न 9उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT COALESCE(NULL, NULL, 30, 40) FROM DUAL;
What will be the result of the following query?
SELECT COALESCE(NULL, NULL, 30, 40) FROM DUAL;
  1. ANULL
  2. B70
  3. C40
  4. D30

सही उत्तर / Answer: (D)

हल / Solution
COALESCE अपने argument को बाएँ से दाएँ देखता है और जो पहला मान NULL नहीं होता उसे लौटाकर रुक जाता है। यहाँ शुरू के दो मान NULL हैं, इसलिए वे छोड़ दिए जाते हैं और तीसरा मान तीस लौट जाता है। चालीस इसलिए नहीं आता कि उससे पहले ही भरा हुआ मान मिल चुका था। सत्तर भी नहीं आता, क्योंकि COALESCE मानों को जोड़ता नहीं, केवल पहला भरा हुआ मान चुनता है।
COALESCE examines its arguments from left to right and stops at the first value that is not NULL, returning it. The first two values here are NULL, so they are skipped and the third value, thirty, is returned. Forty is never reached, because a non null value had already been found before it. Seventy is wrong as well, since COALESCE does not add the values but merely picks the first filled one.
प्रश्न 10उत्तर + हल
निम्नलिखित query का परिणाम क्या होगा?
SELECT NULLIF(100, 100) FROM DUAL;
What will be the result of the following query?
SELECT NULLIF(100, 100) FROM DUAL;
  1. A100
  2. B0
  3. CNULL
  4. D1

सही उत्तर / Answer: (C)

हल / Solution
NULLIF दोनों argument की तुलना करता है। दोनों बराबर हों तो वह NULL लौटाता है, और बराबर न हों तो पहला argument लौटाता है। यहाँ दोनों मान एक ही हैं, इसलिए परिणाम NULL है। सौ तब आता जब दोनों मान अलग-अलग होते। शून्य भी नहीं मिलता, क्योंकि NULLIF घटाव नहीं करता, केवल बराबरी देखता है। एक भी नहीं आता, क्योंकि यह function सच-झूठ का संकेत नहीं लौटाता।
NULLIF compares its two arguments. It returns NULL when the two are equal and returns the first argument when they differ. Both values are the same here, so the result is NULL. One hundred would appear only if the two values had been different. Zero is not produced either, because NULLIF performs no subtraction and only checks equality, and one is wrong because the function returns no true or false flag.
आगे के 15 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 18उत्तर app में
किसी दी गई तिथि के बाद आने वाले पहले निर्दिष्ट वार (जैसे अगला सोमवार) की तिथि कौन-सा function लौटाता है?
Which function returns the date of the first specified weekday (for example, the next Monday) that falls after a given date?
  1. ALAST_DAY
  2. BADD_MONTHS
  3. CNEXT_DAY
  4. DMONTHS_BETWEEN
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
निम्नलिखित query का परिणाम क्या होगा?
SELECT TO_NUMBER('250') + 50 FROM DUAL;
What will be the result of the following query?
SELECT TO_NUMBER('250') + 50 FROM DUAL;
  1. A300
  2. B25050
  3. C250
  4. Dत्रुटि (error), क्योंकि जोड़ नहीं हो सकताError, because the addition is not possible
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Single Row Functions के सभी 25 प्रश्न — उत्तर, हल और अभ्यास

FliQi Question Bank app में topic-वार अभ्यास, कठिनाई-स्तर और आपकी प्रगति।

  • पहला test मुफ़्त
  • हिंदी + English
  • जाँचे हुए उत्तर और हल

यह topic किन परीक्षाओं में आता है

DBMS के दूसरे topics

सभी topics