Sunday, August 23, 2015

DotNet and SQL Server Interview Questions for 3+ yrs of Experienced

1)Get the positive and negative sum for following series by using SQL Query:
Table1:
   Test1
    1
   -4
    4
    6
   -2

Solution:
-----------
(i)
SELECT
  SUM(CASE WHEN test1 > 0 THEN test1 ELSE 0 END) as positives_sum,
  SUM(CASE WHEN test1 < 0 THEN test1 ELSE 0 END) as negatives_sum
FROM
  table1

(ii)
select SUM(test1)from Table1 where test1>0 union
select SUM(test1)   from Table1 where test1<0
  
2)What is Row Number Function in SQL Server ?

Solution:
----------
Assigns unique numbers to each row within the PARTITION given the ORDER BY clause.
 Ex: SELECT test1, ROW_NUMBER() OVER(ORDER BY test1) FROM Table1

3)Difference Between ROW_NUMBER(), RANK(), and DENSE_RANK() 
Solution:
-----------
http://monodroidapp.blogspot.in/2015/08/difference-between-rownumber-rank-and.html

4) How to get Distinct values from given series {1,1,2,3,4,3,8}
Solution:
----------
int[] s = {1,1,2,3,4,3,8};
int[] q = s.Distinct().ToArray();
 
5) C#  Program to Generate Fibonacci Series 
Solution:
--------- 
 http://monodroidapp.blogspot.in/2015/08/c-program-to-generate-fibonacci-series.html
 

No comments:

Post a Comment