Oracle
 sql >> डेटाबेस >  >> RDS >> Oracle

भारतीय नंबरिंग सिस्टम में नंबर को शब्दों में बदलें

SQL Fiddle

Oracle 11g R2 स्कीमा सेटअप :

CREATE TABLE numbers ( value ) AS
SELECT               0 FROM DUAL UNION ALL
SELECT          123456 FROM DUAL UNION ALL
SELECT        12345678 FROM DUAL UNION ALL
SELECT   1234567890123 FROM DUAL UNION ALL
SELECT 123456789012345 FROM DUAL UNION ALL
SELECT 900000000000000 FROM DUAL UNION ALL
SELECT 700000001200000 FROM DUAL UNION ALL
SELECT 543000000000000 FROM DUAL;

क्वेरी 1 :

WITH rsqfc ( original, value, suffix, result, lvl, mxlvl ) AS (
  SELECT value,
         TRUNC( value / 10000000 ),
         CAST( 'CRORE ' AS VARCHAR2(4000) ),
         CAST(
           RTRIM(
             CASE
             WHEN MOD( TRUNC( value / 100000 ), 100 ) > 0
             THEN TO_CHAR(
                    TO_DATE(
                      MOD( TRUNC( value / 100000 ), 100 ),
                      'J'
                    ),
                    'JSP'
                  ) || ' LAKH '
             END
             ||
             CASE
             WHEN value = 0
             THEN 'ZERO'
             WHEN MOD( value, 100000 ) > 0
             THEN TO_CHAR(
                    TO_DATE(
                      MOD( value, 100000 ),
                      'J'
                    ),
                    'JSP'
                  ) || ' '
             END
           )
           AS VARCHAR2(4000)
         ),
         1,
         CEIL( LENGTH( ABS( value ) ) / 7 )
  FROM   numbers
UNION ALL
  SELECT original,
         TRUNC( value / 10000000 ),
         'CRORE ' || suffix,
         RTRIM(
           CASE
           WHEN MOD( TRUNC( value / 100000 ), 100 ) > 0
           THEN TO_CHAR(
                  TO_DATE(
                    MOD( TRUNC( value / 100000 ), 100 ),
                    'J'
                  ),
                  'JSP'
                ) || ' LAKH ' || suffix
           END
           ||
           CASE
           WHEN MOD( value, 100000 ) > 0
           THEN TO_CHAR(
                  TO_DATE(
                    MOD( value, 100000 ),
                    'J'
                  ),
                  'JSP'
                ) || ' ' || suffix
           END
           || result
         ),
         lvl + 1,
         mxlvl
  FROM   rsqfc
  WHERE  lvl < mxlvl
)
SELECT original, result
FROM   rsqfc
WHERE  lvl = mxlvl

परिणाम :

|        ORIGINAL |                                                                                                                                           RESULT |
|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
|               0 |                                                                                                                                             ZERO |
|          123456 |                                                                                            ONE LAKH TWENTY-THREE THOUSAND FOUR HUNDRED FIFTY-SIX |
|        12345678 |                                                                        ONE CRORE TWENTY-THREE LAKH FORTY-FIVE THOUSAND SIX HUNDRED SEVENTY-EIGHT |
|   1234567890123 |                    ONE LAKH CRORE TWENTY-THREE THOUSAND FOUR HUNDRED FIFTY-SIX CRORE SEVENTY-EIGHT LAKH NINETY THOUSAND ONE HUNDRED TWENTY-THREE |
| 123456789012345 | ONE CRORE CRORE TWENTY-THREE LAKH CRORE FORTY-FIVE THOUSAND SIX HUNDRED SEVENTY-EIGHT CRORE NINETY LAKH TWELVE THOUSAND THREE HUNDRED FORTY-FIVE |
| 900000000000000 |                                                                                                                                 NINE CRORE CRORE |
| 700000001200000 |                                                                                                                    SEVEN CRORE CRORE TWELVE LAKH |
| 543000000000000 |                                                                                                          FIVE CRORE CRORE FORTY-THREE LAKH CRORE |



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. SQLcl (Oracle) का उपयोग करते समय किसी XML फ़ाइल में क्वेरी परिणाम निर्यात करें

  2. Oracle में SQL सर्वर APPLY के बराबर क्या है?

  3. कौन सा डाउनलोड करना है:JDK या JRE?

  4. JDBC प्रकार स्क्रॉल असंवेदनशील और संवेदनशील

  5. एक बड़ी Oracle तालिका में CLOB डुप्लिकेट की गणना करें