Convert number to words - first, second, third and so on

前端 未结 5 1279
清酒与你
清酒与你 2020-12-09 12:43

Does anyone know how if it\'s possible to take an integer variable in SQL and convert it to the equivilent number of the form: First, Second, Third, Fourth etc?

Than

5条回答
  •  余生分开走
    2020-12-09 13:02

    Also, you can CREATE TABLE with numbers and their names.

    CREATE TABLE tblNumbers (Nmb int, NmbWord varchar(100))
    INSERT INTO tblNumbers 
    VALUES (1,'first'), (2,'second'),(3,'third'), (4,'forth')
    
    CREATE TABLE SomeTable (nmb int)
    
    INSERT INTO SomeTable 
    VALUES (1), (1),(2),(3)
    
    SELECT  N.*
    FROM tblNumbers N
         JOIN SomeTable ST ON ST.nmb=N.Nmb
    
    DROP TABLE tblNumbers
    DROP TABLE SomeTable
    

提交回复
热议问题