Simple Oracle variable SQL Assignment

后端 未结 5 519
一整个雨季
一整个雨季 2021-01-17 20:35

Despite having spent an hour researching I can\'t seem to figure out how to correctly define a variable and then use it in your SQL.

This is what I have so far produ

5条回答
  •  终归单人心
    2021-01-17 20:53

    This is an old post, but in case anyone stumbles on this (as I just did), you can handle this with a CTE:

    with params as (
          select date '2011-11-03' as startdate
          from dual
         )
    select . . .
    from params cross join
         . . .
    

    Almost the same syntax works in SQL Server (minus the date-specific stuff and from dual).

提交回复
热议问题