SELECT DISTINCT does not work. Why?

Dear All,
I wrote the Query below in SAP B1 8.8 and it works fine.
But, for some strange reason, certain records are duplicated.
Could anybody explain why?
I tried to eliminate the duplicates by changing the 1st line of the Query from SELECT to SELECT DISTINCT
Error Message:
The ntext data type cannot be selected as DISTINCT because it is not comparable.
Could you help amend the Query?
Thanks
Leon Lai
SELECT
T0.[UpdateDate] AS 'Update Dt',
T0.[TaxDate] AS 'Doc Dt',
CASE T5.[TransType]
     WHEN '18' THEN 'PU ' + CONVERT(VARCHAR(6), T0.[DocNum])
     WHEN '19' THEN 'PC ' + CONVERT(VARCHAR(6), T0.[DocNum])
END 'SAP Ref.',
T1.[ImportLog]     AS 'Ship #',
T0.[CardCode] + '' AS 'Supplier #',
T0.[CardName]      AS 'Supplier Name',
T0.[DocTotal]      AS 'Rs',
T1.[BlockNum]      AS 'Reqn #',
T0.[DocNum]        AS 'Doc No',
T0.[U_SupInv]      AS 'Link'
FROM klship.[dbo].[OPCH] T0
INNER JOIN klship.[dbo].[PCH1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN klship.[dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID]
WHERE
(T0.[UpdateDate] >= '[%2]' AND
T0.[UpdateDate]  <= '[%3]' AND
T0.[U_SupInv] IS NULL)
OR
(T0.[UpdateDate] >= '[%4]' AND
T0.[UpdateDate]  <= '[%5]' AND
T0.[U_SupInv] IS NOT NULL)
FOR BROWSE
Note: -  U_SupInv is a UDF used to attach a scanned pdf file to the Supplier's Invoice.

Dear István Korös,
Thanks a lot for your answer.
Your suggestion works!
I am closing this thread.
However, I have never met the problem of duplicate records before
with such straightforward Queries.
If you could explain to me why such duplicates arose, it would be very
satisfying.
Best Regards
Leon Lai

Similar Messages

  • SELECT DISTINCT does not work - Another Problem!

    Dear All
    Previous Post
    I just posted a thread, which has been answered by an expert. It's here:
    SELECT DISTINCT does not work. Why?
    My original problem was that the Query returned duplicate records, and SELECT DISTINCT did not work.
    The solution was to change this select:
    T0.[U_SupInv]      AS 'Link'
    ... to this:
    CAST(T0.[U_SupInv] as nvarchar(100))      AS 'Link'
    The amended Query worked.
    New Problem
    I just discovered that resolving the problem created a new one.
    The field U_SupInv (Link) is in fact a UDF.
    I created it so that all Suppliers' Invoices could be Scanned to pdf files, and these pdf could be linked
    to the respective AP Invoice.
    Originally, when I clicked 'Link' in my Query results, the pdf scan pops up.
    When the Query is amended by adding CAST, the link becomes dead.
    Help
    Could anyone tell me how I can make SELECT DISTINCT work, as well keeping the LINKS live?
    The main purpose of my Query is to help users view the pdf scans by clicking on the links.
    Thanks
    Leon Lai
    Here's my Original Query
    SELECT
    T0.[UpdateDate] AS 'Update Dt',
    T0.[TaxDate] AS 'Doc Dt',
    CASE T5.[TransType]
         WHEN '18' THEN 'PU ' + CONVERT(VARCHAR(6), T0.[DocNum])
         WHEN '19' THEN 'PC ' + CONVERT(VARCHAR(6), T0.[DocNum])
    END 'SAP Ref.',
    T1.[ImportLog]     AS 'Ship #',
    T0.[CardCode] + '' AS 'Supplier #',
    T0.[CardName]      AS 'Supplier Name',
    T0.[DocTotal]      AS 'Rs',
    T1.[BlockNum]      AS 'Reqn #',
    T0.[DocNum]        AS 'Doc No',
    T0.[U_SupInv]      AS 'Link'
    FROM klship.[dbo].[OPCH] T0
    INNER JOIN klship.[dbo].[PCH1] T1 ON T0.[DocEntry] = T1.[DocEntry]
    INNER JOIN klship.[dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID]
    WHERE
    (T0.[UpdateDate] >= '[%2]' AND
    T0.[UpdateDate]  <= '[%3]' AND
    T0.[U_SupInv] IS NULL)
    OR
    (T0.[UpdateDate] >= '[%4]' AND
    T0.[UpdateDate]  <= '[%5]' AND
    T0.[U_SupInv] IS NOT NULL)
    FOR BROWSE

    Dear István Korös,
    Thanks a lot for your answer.
    I will test your suggestion tomorrow, as it's night and I am returning home now.
    However, I do not think it will suit my requirements for the foll reasons:
    - I worked hard to get rid of the need to enter anything in the @Scan2 field.
    - This UDF was created solely as a text of instruction for my staff.
       Unfortunately I had to fill in something to make the Query work.
    - The problem is that if the user forgets to click the drop-down arrow and leaves @Scan2
       blank, the query does not work.
    - With the help of another expert, I succeeded in ignoring @Scan2 altogether.
    - I posted only a simplified version of my Query on the forum, without the codes relating to eliminating the
      need to enter something in @Scan2, so you may not be aware of my requirement.
    - I hope you understand my reluctance. But I will try your suggestion nevertheless.
    My Suggestion
    I think using PCH1.VISORDER may be the solution.
    If we select only those rows where visorder = 0, then
       - there will be no duplication
       - I need not use SELECT DISTINCT
       - All my LINKS to pdf files will be live because I need not use CAST
       - I may retain that part of my Query which permits ignoring @Scan2 altogether.
    - A Dream!-
    The problem is that I don't know how and where  to place that VISORDER.
    If you think I may be right, could you help me along that line?
    Best Regards
    Leon Lai

  • Hello, I just did an update and now the second Language - Hebrew - does not working. why?

    Hello, I just did an update and now the second Language - Hebrew - does not working. why?

    More information please.
    If you are on adobe cloud, download indesign that support hebrew from CC desktop. Click on the preference gear on the top right then select App language.

  • I have tried to reinstall CS3 extended student version to my new comuter from the dvd and also from the web download but it does not work - I get the information that the server does not work- why. How should I do?

    I have tried to reinstall CS3 extended student version to my new comuter from the dvd and also from the web download but it does not work - I get the information that the server does not work- why. How should I do?

    Well the error message is in Swedish but says: The installation program database is damaged. Please contact the Adobe support (which is a hard thing to do!!). I use Windows 7 Home Premium with service pack 1.
    Från: Mylenium 
    Skickat: den 29 december 2014 16:48
    Till: Tony Bohman
    Ämne:  I have tried to reinstall CS3 extended student version to my new comuter from the dvd and also from the web download but it does not work - I get the information that the server does not work- why. How should I do?
    I have tried to reinstall CS3 extended student version to my new comuter from the dvd and also from the web download but it does not work - I get the information that the server does not work- why. How should I do?
    created by Mylenium <https://forums.adobe.com/people/Mylenium>  in Downloading, Installing, Setting Up - View the full discussion <https://forums.adobe.com/message/7050595#7050595>

  • Multi-select LOV does not work in forms

    the multi select LOV does not work in the form.
    the LOV works individually but in the form it does not work. it does not allow multiple selection from the list.
    is there a workaround for this or is this a bug ...?
    any ideas ...?
    thanx a lot.
    null

    Right, we cannot store more than one value in a single column in a table :), we were getting a lot of requests to support multiple select LOVs but requirements were contradictory if not mutually exclusive.
    The only sense it makes is when used together with user-defined object types (nested tables for example) but the current [application building]infrastructure we have does not support this. However, we are looking into this and this feature maybe implemented in a future release.

  • Double click select all does not work in web site's search area after going back.

    After updating from Firefox ESR v24.8.1 to v31.20 double click select all does not work in a search area after going back or searching again with the same input. It happens before clicking search icon and searching for something else double click select all does not work except it works for one word that's all.
    This issue is with all new Firefox ESR and None ESR I have tried. Also the issue is on all web sites like www.softpedia.com for example.

    Bugzilla has a different login system, unfortunately.

  • The Restriction option to NOT ALLOW CHANGES to Mobile or Cellular data does not work why is this ?

    The Restriction option to NOT ALLOW CHANGES to Mobile or Cellular data does not work why is this ?

    Hi there,
    You may want to try force closing all open apps and resetting the device as an initial troubleshooting step. Take a look at the articles below for more information.
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Turn your iOS device off and on (restart) and reset
    http://support.apple.com/kb/ht1430
    Additionally, you may want to try completely disabling and re-enabling restrictions.
    -Griff W.

  • Zen Micro 5gb - Playlist on the fly with "add to selected" often does not work (AD HOC 'playlis

    I've found ad-hoc playlist made from ADD TO SELECTED often does not work. Here are other issues:?. Does not add? at all OR only adds after first song selected played2. Cannot swith from ARTISTS to SONGS w/o killing list. This will kill the ongoing list.3. If I make mistake and hit the PLAY button, it wipes out the entire list I'd already made. Any of these issues resolved in Zen Vision M?

    try reloading the firmware and if that doesnt work try opening the case and cleaning it if there is anything in there. the button may be stuck. and if that doesnt work i dont know what else to sugjest. it seemed to work for me.

  • Added field to dynamic selection screen does not work in FBL5N

    hi,
    we have added KNA1-KATR5 to the selection screen of FBL5N by using logical database DDF using "view CUS" but it does not work.
    Our system is 6.0
    is there any OSS note or program that we should add?
    many thx.

    Refer This:
    Additional field selections in FB03

  • Selection Tool does not work

    Hi, everyone, I noticed that the Selection tool (V) does not work properly, I use Ai CS3, and I can`t resize,move or select any object or text, Can anyone help me?
    Thanks a lot
    Diana

    Sounds like "Preferences>Selection & Anchor Display>Object Selection by Path only" is on.

  • Dictionary and selecting words does not work for Japanese documents

    iOS 5 includes both English and Japanese dictionaries. However, it seems that dictionary function does not work for Japanese PDF documents, nor can I select any Japanese words in Adobe Reader. Please fix this!
    Thanks,
    Kenny

    You can start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).<br />
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.<br />
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.<br />
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")<br />

  • Firefox updated, Video download helper no longer works, no error msg. I have uninstalled both Firefox and VDH, reinstalled, VDH still does not work, Why

    Video Download Helper does not work after most recent update. I have cleared cache and cookies, uninstalled both Firefox and the helper,that has not corrected.When Firefox does an update are the "vendors notified so they can see if their product needs changes in order to be compatible? This may sound like a stupid ?, but it makes sense tome. Telling me to download something else, in my eyes is not REALLY solving the problem.

    Don't uninstall 36. Just download and install 35 over top and you don't lose any data. I already did and everything works just fine. But I did remove VDH first.

  • When i paint either black or white on layer mask it erases picture pixels also path selection tool does not work

    when I paint either in black or white on layer mask it erases picture pixels also path tool does not work

    I would try resetting your preference file first:  http://www.lightroomforums.net/showthread.php?14226-Resetting-(or-Trashing-)-the-Lightroom -Preferences-file
    Also, install the latest version 4.4.1 would probably be a good idea.

  • My home button does not work. why?

    What is wrong with THE iPad Home button.  Only a couple of months old. Moderate use at most and the Home button does not work at all.  Is this easily sorted out or should the iPad be replaced?

    Bring it to a Store. Hardware problems are best sorted out there. Until then use multi-touch-gestures. HOpe this helps.

  • Select button does not work

    I have a Classic Ipod 60G and I have almost 6,000 songs on it. I also have my contacts from outlook and my photos from Adobe Photoshop. It is only half full. It is stuck on "songs" and I cannot choose the music I want to hear and I cannot access my photos, settings, contacts, etc. I've upgraded Itunes automatically and am currently on Version 10 and my music is synced with Itunes and any new music automatically downloads to my Ipod. But cannot hear them because my select button will not click to change from songs to "playlist or artist". What do I do? My old Ipod, a 15G classic has no problem, but my newer 60G has a stuck program or a stuck button. Which is it?

    I also had the same problem. After reading many suggestions on how to fix, I tried the one that seems to work for many people.  I plugged my apple tv into my pc ( itunes) and it automatically asked if I would like to restore it and  that it will download any updated software.  I followed the instructions and when it was complete I tried it out and it worked perfectly. When Apple TV is plugged into your pc it does not need any power. Also you need to use a micro usb to connect it.  Hope this will help!
    There was a problem for a short while (see link below) but as of a few days ago you no longer have to do anything special to update the Apple TV2 since Apple released v4.4.2.  All you need to do is go to Setttings > General > Update and it will automatically update to v4.2.2 from any earlier version.
    http://support.apple.com/kb/TS4107

Maybe you are looking for

  • How do i set a locking code to my macBook Pro?

    How do I set a locking code on my MacBook Pro?

  • Microsoft word crashes when I open a file or try to save document

    Every time I try to open an existing document or save a new one Microsoft word crashes.  I am able to start a new document but if I try to save it all of the action/editing buttons fade/unhighlight (save, print, quit, copy paste, etc) and I am ubable

  • Upgrade to Adobe 9 pro breaks scanner compatibility

    I have been using Adobe 7 Standard and Adobe 8 Standard to create PDF documents from my flatbed scanner (Microtek ScanMaker S400). This had been working fine until I upgraded to Adobe 9 Professinal about 2 months ago. Now, when I try to create a  PDF

  • MS SQL to Oracle 8.1.6/7

    When using Migration WB on SQL server 7 users are by default migrated too, this includes the standard MS SQL user 'sa' and in my case another user 'A'. When migrating since all tables in the SQL db was created by 'sa' so will they be in oracle. This

  • How can pass the Maximum query String parameter in browser.....?? (URGENT)

    hi Guys, i make the application, in which lots of data record with id, whenever i clicked to the SUBMIT button, it wil forwarded to the next page. But The problem is.....when we pass the 30 id in a query string parameter that' fine but when it is inc