Which are the SQL improvements you are waiting for?

后端 未结 30 1253
感情败类
感情败类 2021-02-01 22:29

Dealing with SQL shows us some limitations and gives us an opportunity to imagine what could be.

Which improvements to SQL are you waiting for? Which would you put on t

30条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 22:53

    Ability to define columns based on other columns ad infinitum (including disambiguation).

    This is a contrived example and not a real world case, but I think you'll see where I'm going:

    SELECT LTRIM(t1.a) AS [a.new]
        ,REPLICATE(' ', 20 - LEN([a.new])) + [a.new] AS [a.conformed]
        ,LEN([a.conformed]) as [a.length]
    FROM t1
    INNER JOIN TABLE t2
        ON [a.new] = t2.a
    ORDER BY [a.new]
    

    instead of:

    SELECT LTRIM(t1.a) AS [a.new]
        ,REPLICATE(' ', 20 - LEN(LTRIM(t1.a))) + LTRIM(t1.a) AS [a.conformed]
        ,LEN(REPLICATE(' ', 20 - LEN(LTRIM(t1.a))) + LTRIM(t1.a)) as [a.length]
    FROM t1
    INNER JOIN TABLE t2
        ON LTRIM(t1.a) = t2.a
    ORDER BY LTRIM(t1.a)
    

    Right now, in SQL Server 2005 and up, I would use a CTE and build up in successive layers.

提交回复
热议问题