Star Pattern by SQL in Oracle Database

Star Patterns by SQL in Oracle -
nimish@garg> select lpad('*',level,'*') from dual connect by level <= 5;

LPAD('*',LEVEL,'*')
---------------------------------------------------------------------------------

*
**
***
****
*****


nimish@garg> select lpad('*',5-level+1,'*') from dual connect by level <= 5;

LPAD('*',5-LEVEL+1,'*')
---------------------------------------------------------------------------------

*****
****
***
**
*


nimish@garg> select lpad(' ',5-level,' ') || lpad('*',level,'*') from dual connect by level <= 5;

LPAD('',5-LEVEL,'')||LPAD('*',LEVEL,'*')
------------------------------------------------------------------------------------------------------

    *
   **
  ***
 ****
*****


nimish@garg> select lpad(' ',level-1,' ') || lpad('*',5-level+1,'*') from dual connect by level <= 5;

LPAD('',LEVEL-1,'')||LPAD('*',5-LEVEL+1,'*')
---------------------------------------------------------------------------------------------------------

*****
 ****
  ***
   **
    *
    
    
nimish@garg> select lpad('*',5-level+1,'*') || lpad('*',level*2-1,' ') || lpad('*',5-level,'*') star_pattern
  2  from dual connect by level <= 5
  3  union all
  4  select lpad('*',level,'*') || lpad('*',(5-level)*2+1,' ') || lpad('*',level-1,'*')
  5  from dual connect by level <= 5;

STAR_PATTERN
-----------------------------------------------------------------------------------------------------------------

**********
****  ****
***    ***
**      **
*        *
*        *
**      **
***    ***
****  ****
**********

10 rows selected.

nimish@garg> select lpad(' ',5-level+1,' ') || lpad('*',level*2-1,'*') diamond
  2  from dual connect by level <= 5
  3  union all
  4  select lpad(' ',level+1,' ') || lpad('*',(5-level)*2-1,'*') diamond
  5  from dual connect by level <= 5;

DIAMOND
-----------------------------------------------------------------------------------------------------------------

     *
    ***
   *****
  *******
 *********
  *******
   *****
    ***
     *

10 rows selected.


Related Posts -
 

8 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi Sir/madam Great article and is appreciable. Great work and keep it up to the level of the sky. But sir/madam your article is incomplete and needs some moderation. I would suggest you to visit This article for complete information and making your article worth rewarding. But if you want a complete warehouse of articles on some interesting topics then visit This website . I hope you understood and may bright as a star in future. Cheers

    ReplyDelete
  3. This site helps to clear your all query. vikram university ba 3rd year result
    vikram university bsc 3rd year result This is really worth reading. nice informative article.

    ReplyDelete
  4. Awesome blog, thank you so much for sharing such an amazing information with us. Visit Preetidevelopers for Developers Real Estate, Royal Estate, Muda Mysore, and Villa Projects in Bangalore.
    Developers Real Estate

    ReplyDelete
  5. โปรโมชั่น pg slot รวมโปรสล็อต PG โปรโมชั่นดีๆสุดพิเศษและก็ร้อนแรงมาเสนอแนะสำหรับคุณ สำหรับสาวกสล็อตตัวจริงต้องห้ามพลาดกับโปรโมชั่นที่พวกเราเตรียมความพร้อมมายกให้คุณทุกวัน

    ReplyDelete