I would like to set a default value to a variable
SELECT ID, VALUE
FROM TABLE
Now I would like that value to have a default value of 0 for every ID. What can I do?
I would like to set a default value to a variable
SELECT ID, VALUE
FROM TABLE
Now I would like that value to have a default value of 0 for every ID. What can I do?
Are you asking how to specify a default value in the select:
SELECT ID, 0 as VALUE FROM TABLE
Or do you want to have the underlying table column have a default value?
If you mean you want a default value for when the column is null then you can use the NVL function (at least in oracle), e.g.
SELECT NVL(thecol, 0) FROM thetable;
select id, 0 as value_default from myTable
so you have an initial default value assigned against a named column (the value of which you can change).
SELECT ID, IFNULL(VALUE,0) as Value
FROM MyTable
This will select ID, and Value. If value is null it will display 0