2 Replies Latest reply on Nov 20, 2016 9:59 AM by Daniel Andersen

    Custom SQL where clause

    Daniel Andersen

      Hi guys!

       

      Can you please help me with my challenge. I have a table like this:

        

      Account Amount Budgetcode

      1.000 100.000      0

      1.000 150.000      1

      2.000 50.000        0

      2.000 40.000        1

      3.000 150.000      0

      3.000 100.000      1

       

      I need to write a custom sql where [Amount] will be splitted up into one where [Budgetcode]=1 and one where [Budgetcode]=0. Im new to SQL but in my mind it should be something like:

       

      SELECT

        [LEDTRANS].[ACCOUNT] AS [ACCOUNT],

        [LEDTRANS].[BUDGETCODE] AS [BUDGETCODE],

        [LEDTRANS].[AMOUNTMST] WHERE [LEDTRANS].[BUDGETCODE] =0 AS [BUDGET],

        [LEDTRANS].[AMOUNTMST] WHERE [LEDTRANS].[BUDGETCODE] =1 AS [REAL]

      FROM [dbo].[LEDTRANS] [LEDTRANS]

       

      How do I do it?? :-)