help with my query with expressions

  • hi guys , i need help with my espressions in this view..... my espressionskeep giving me an error message... can anyone help?

     

    SELECT     dbo.[query 2 b ].Expr1, dbo.[query 2 b ].Expr1 AS Customer_No,

                          MAX(dbo.[query 2 b ].Invoice_Date) AS MaxofInvoice_Date, MIN(dbo.[query 2 b ].Invoice_Date)

                          AS MinOfInvoice_Date, [MinofInvoice_Date] AS [Min], dbo.[Information Query for Customers].CustomerName, dbo.[Sales].[Sales Representative],

                          dbo.[Sales].[Customer Type], dbo.[Sales].[Bonus Check Date], dbo.[query 2 b ]._Facility_ID,

                          COUNT(dbo.[query 2 b ].Expr1) AS Expr9, dbo.[query 2 b ].PM_Parent_ID, DATEDIFF(Day, MaxofInvoice_Date, MinOfInvoice_Date)AS Expr2,

                          CASE When([Expr12]>= 90 then 1 else 0) AS Expr14,  DATEDIFF(DAY, GETDATE()-[MinOfInvoice_Date])AS Expr12

    FROM         dbo.[query 2 b ] LEFT OUTER JOIN

                          dbo.[Information Query for Customers] ON dbo.[query 2 b ].Expr1 = dbo.[Information Query for Customers].Expr1 LEFT OUTER JOIN

                          dbo.Cross_Refference ON dbo.[Information Query for Customers].Expr1 = dbo.Cross_Refference.Customer_No LEFT OUTER JOIN

                          dbo.[Sales] ON dbo.Cross_Refference.Customer_No = dbo.[Sales].Customer_No

    WHERE     (dbo.[Sales].[Sales Representative] = 'Lucy') AND (dbo.[Sales].[Customer Type] = 'New')

    GROUP BY dbo.[query 2 b ].Expr1, dbo.[query 2 b ].Expr1, dbo.[Information Query for Customers].CustomerName,

                          dbo.[Sales].[Sales Representative], dbo.[Sales].[Customer Type], dbo.[Sales].[Bonus Check Date],

                          dbo.[query 2 b ]._Facility_ID, dbo.[query 2 b ].PM_Parent_ID

     

    I would really apreciate it!!!

    Jessica

  • SELECT dbo.[query 2 b ].Expr1, dbo.[query 2 b ].Expr1 AS Customer_No,

    MAX(dbo.[query 2 b ].Invoice_Date) AS MaxofInvoice_Date, MIN(dbo.[query 2 b ].Invoice_Date)

    AS MinOfInvoice_Date, [MinofInvoice_Date] AS [Min], dbo.[Information Query for Customers].CustomerName, dbo.[Sales].[Sales Representative],

    dbo.[Sales].[Customer Type], dbo.[Sales].[Bonus Check Date], dbo.[query 2 b ]._Facility_ID,

    COUNT(dbo.[query 2 b ].Expr1) AS Expr9, dbo.[query 2 b ].PM_Parent_ID, DATEDIFF(Day, MaxofInvoice_Date, MinOfInvoice_Date)AS Expr2,

    CASE

    When [Expr12]>= 90 then 1 else 0 end AS Expr14,

    DATEDIFF(DAY, GETDATE(),[MinOfInvoice_Date])AS Expr12

    FROM dbo.[query 2 b ] LEFT OUTER JOIN

    dbo.[Information Query for Customers] ON dbo.[query 2 b ].Expr1 = dbo.[Information Query for Customers].Expr1 LEFT OUTER JOIN

    dbo.Cross_Refference ON dbo.[Information Query for Customers].Expr1 = dbo.Cross_Refference.Customer_No LEFT OUTER JOIN

    dbo.[Sales] ON dbo.Cross_Refference.Customer_No = dbo.[Sales].Customer_No

    WHERE (dbo.[Sales].[Sales Representative] = 'Lucy') AND (dbo.[Sales].[Customer Type] = 'New')

    GROUP BY dbo.[query 2 b ].Expr1, dbo.[query 2 b ].Expr1, dbo.[Information Query for Customers].CustomerName,

    dbo.[Sales].[Sales Representative], dbo.[Sales].[Customer Type], dbo.[Sales].[Bonus Check Date],

    dbo.[query 2 b ]._Facility_ID, dbo.[query 2 b ].PM_Parent_ID

  • hi, thank you , but still get the same errors:

     

    Server: Msg 207, Level 16, State 3, Line 1

    Invalid column name 'MinofInvoice_Date'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'MinOfInvoice_Date'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'MaxofInvoice_Date'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'Expr12'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'MinOfInvoice_Date'.

     

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply