1

I have a table which contains data of ledger. it contains field Account name,debit credit. the data entered in the table at end of month ie. sum of all the days.

Here my problem is that i want to display data of two months i.e current month and the back month. the real problem is that it will be displayed in crosstab

Accname    dated     debit     credit
-------    -----     ------    ------

Account name will be in both the months and i want to display one entry from both the month and its corresponding data ie credit and debit field will fill. The query will work on two conditions fields the account name and dated which is to be checked.

Is it possible to use case statement in the query

PLease Help

1
  • 6
    I think you'll need to provide some sample data and a desired result, I can't quite understand what you're asking. Commented Jul 18, 2013 at 9:30

1 Answer 1

1

SQL Server/SQL does not display anything by default. So it doesn't really matter in what form you return the data from your query, as long as it is then visualized the way you want it. Just write your query to return the required data and then care about the visualization.

It might also help us if you told us how you're planning to visualize the data.

To answer your question: Yes, you can use CASE within a query as in

SELECT
    CASE WHEN <Condition1> THEN <Value1>
         WHEN <Condition2> THEN <Value2>
         ELSE <Value3>
    END AS <FieldName>
Sign up to request clarification or add additional context in comments.

1 Comment

Which wasn't there when I made my last comment - so I have now removed that comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.