You must Sign In to post a response.
  • Category: SQL Server

    How to display orderno with its quantity

    I HAVE order table
    OrdersNo RevisionNo Quantity
    O-1 0 2
    O-1 1 3
    O-2 0 5

    The above data i need to get at PurchaseOrder screeN like below
    O-1 1 3
    O-2 0 5

    AND IF WE CREATE PURCHASE ORDER OF ORDERNO O-1 FOR 1 QAUNTITY
    THEN DATA SHOULD DISPLAY LIKE BELOW
    O-1 1 2
    O-2 0 5
  • #767950
    Select distinct a.orderno (a.qty-isnull(sum(b.qty),0)) from orders as a left outer join purchase as b on a.orderno=b.orderno group by a.orderno, a.qty

  • #767954
    Hi,

    Use below query


    select OrderNo, Max(RevisionNo), Quantity
    from purchaseorder
    where yourconditions
    Group By OrderNo, Quantity


    Hope this helps you..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments