[Solved] Whats wrong with my SQL?

Your last query SELECT 0, department, department_name, ”, ‘NP’ as acc_code, ‘NET PROFIT/(LOSS)’ as acc_name,1, SUM((CASE WHEN acc_code=”CS” OR acc_code=”EX” THEN -1*yr_balance ELSE yr_balance END)), SUM((CASE WHEN acc_code=”CS” OR acc_code=”EX” THEN -1*ly_balance ELSE ly_balance END)), SUM((CASE WHEN acc_code=”CS” OR acc_code=”EX” THEN -1*mn_balance ELSE mn_balance END)), SUM((CASE WHEN acc_code=”CS” OR acc_code=”EX” THEN -1*lm_balance ELSE lm_balance END)), … Read more

[Solved] How can I retrieve first second and third word of a String in SQL?

If you don’t want to create a dedicated function, you can use successive CROSS APPLYs: SELECT T.s, FirstSpace.i, SecondSpace.j, ThirdSpace.k, CASE When ThirdSpace.k > 0 THEN LEFT(T.s, Thirdspace.k – 1) ELSE T.S END AS Phrase FROM t CROSS APPLY (SELECT CHARINDEX(‘ ‘, T.s, 1)) AS FirstSpace(i) CROSS APPLY (SELECT CHARINDEX(‘ ‘, T.S, FirstSpace.i + 1)) … Read more

[Solved] How do we make Microsoft SQL Server Management Studio behave in a More Prompt Manner?

Other than the number of rows affected by a query, you can also display the the steps that your database server actually performed to execute your query. This is often called the “execution plan”. In SQL Server Management Studio, you can select the Include Actual Execution Plan (Ctrl+M) option prior to executing your query. Following … Read more