locked
Query RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below query , when run in Query Designer it works fine . When i run Preview it does not show effect of 

    left(A.[Document No_],1)='T' , it shows all entries

    SELECT A.[Posting Date],A.[Document No_] ,A.[Description],A.[Debit Amount] 
    FROM Test as A where A.[Debit Amount] > 0 and left(A.[Document No_],1)='T'

    Thanks

    Friday, March 2, 2018 10:28 AM

All replies

  • User516094431 posted

    SELECT A.[Posting Date],A.[Document No_] ,A.[Description],A.[Debit Amount] 
    FROM Test as A where A.[Debit Amount] > 0 and left(A.[Document No_],1)='T'

    I think you had mistake in column name. check following code:

    CREATE TABLE #Test (Document_No_ VARCHAR(10), Description VARCHAR(MAX),  Debit_Amount INT);
    
    INSERT INTO #Test VALUES ('T1232', 'This is for testing', 50)
    INSERT INTO #Test VALUES ('S1232', 'This is for testing', 150)
    INSERT INTO #Test VALUES ('T4354', 'This is for testing', 250)
    INSERT INTO #Test VALUES ('T65756', 'This is for testing', 0)
    
    SELECT A.[Document_No_] ,A.[Description],A.[Debit_Amount] 
    FROM #Test as A where A.[Debit_Amount] > 0 and left(A.[Document_No_],1)='T'

    Tuesday, March 6, 2018 10:59 AM
  • User347430248 posted

    Hi JagjitSingh,

    Did you try to create a sample query and just try to use the Left function in Where clause of the query?

    If you did not try it then you can try to make a test with it and let us know whether it shows you correct result or not.

    We will try to provide you further suggestions to solve the issue.

    Regards

    Deepak

    Friday, March 9, 2018 8:51 AM