If a table has a column "dept" (declared to have nulls) and
there are 10 rows in the table of which 3 have a null value
in the dept column, what will select count(*) and select
count(distinct dept) return?
Answers were Sorted based on User's Feedback
Answer / virender
SELECT(*) Will return 10 and SELECT (distinct dept) will
return 8.
| Is This Answer Correct ? | 7 Yes | 2 No |
Answer / madhuri tungal
select count(*) returns 10 --- this is right. But,
select count(distinct dept) returns 7. Because null values
are not considered as distinct.
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / abhilash
SELECT(*) Will return 10 and SELECT (distinct dept) will
return 8.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is concurrency in db2?
What is reorg and runstats in db2?
wht r the requirements for writing a cobol-db2 pgm ?
What's the maximum number of characters that a tablename can have?
is it possible to get -811 error when you use cursors. why?
What are the functions in DB2?
SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.
What is the use of commit in db2?
What is difference between rollback and commit?
I use CS and update a page. Will the lock be released after I am done with that page?
What is REORG? When is it used?
Is Cursor exicutable ?