How to calculate balance on the bases of previous record?
Hi All, i am currently facing an issue and hope that someone will help me. here is the scenario. I have a simple table. Member Table ================ Member_id Member Name Opening Balance Opening...
View ArticleProblem in counting nulls and then merging them with the rows
**Input:** ID groupId RowID Data 1 1 1 W 2 1 1 NULL 3 1 1 NULL 4 1 1 Z 5 1 2 NULL 6 1 2 NULL 7 1 2 X 8 1 2 NULL 9 1 3 NULL 10 1 3 NULL 11 1 3 Y 12 1 3 NULL **Expected Output** GroupId NewData 1...
View ArticleHow to run expression in string format
Hello, I have created a table to store formulae for different projects. How can I convert data to expression in SQL to return value instead of formula?
View ArticleUsing CTE Common table expressions with SELECT CASE statement
Hi, This gives me error. DECLARE @r INT SELECT @r = 1 ;WITH sam AS (select * from test) SELECT 1, CASE @r WHEN 1 THEN (SELECT * FROM sam) WHEN 2 THEN 200 ELSE 0 END Msg 156, Level 15, State 1, Line 5...
View ArticleWhich is better? CTEs (common table expressions) or Subqueries?
Seeder question. In SQL2005 and beyond, you can use CTEs or you can continue to use subqueries. What are the pros and cons of each?
View Article