What does "Select Distinct Null As xxxxx" mean?

Posted by Soylent Green on Stack Overflow See other posts from Stack Overflow or by Soylent Green
Published on 2013-10-18T15:39:01Z Indexed on 2013/10/18 15:54 UTC
Read the original article Hit count: 173

Filed under:
|
|
|
|

Background: I am mapping Sybase stored procedure return values to java objects using Spring.

For example I map a Sybase datatype of varchar as a String type in Java, and a Sybase datatype of int as an int type in Java, etc.

I have come across the following code in one of the stored procedures:

SELECT DISTINCT
    A.Col1 AS val1,
    A.Col2 AS val2,
    NULL AS someVal,
    A.col3 AS val3,
    ...
    A.col9 AS val9
FROM #SomeTable A
ORDER BY Col2, Col3

I have 2 related questions:

  1. What does Null mean in this scenario? I am confused as to what is happening here.

  2. I am able to determine the data type of Col1, Col2, etc. of course by looking at the table definition of Table A defined earlier in the stored procedure. Thus I know what datatype I can define in my Java object for val1, val2, etc.. But what about "someVal"? What datatype mapping am I supposed to perform for this Null value?

I am fairly inexperienced in SQL. Perhaps the answer is much simpler than I realize.

© Stack Overflow or respective owner

Related posts about java

Related posts about sql