sql - Select Max Row from Column -
i have scan codes used in table, table doesn't save newest scan codes. have order numbers multiple items on orders.
the issue need last scan code on each item number each order , not every time has been scanned. don't need know has been scanned prep customization shipping. need know in shipping. 3 results 1 item number because has been scanned 3 times.i don't need duplicate result has been scanned.
the "s3dtnseq#" column number of times has been scanned.i need keep rows highest scan count. lower highest scan count need rid of. 'scan to' column "s3dtsto". using "s3dtnseq#" column determine row kept idea.
select tmon "order number", tmcpo# "po#", tmrqd "due date", s3itno "item number", s3orqt "quantity", tmcust "cust#", tmname as, "cust name" s3dtsto "scanned to", tmschid "sched id, max( s3dtnseq# ) "s3dtnseq#", s3dtadt "maintained date" tsa400.nrpdta.sop114f1 sop114f1, tsa400.nrpdta.soa soa, tsa400.nrpdta.s3o s3o, tsa400.nrpdta.s3dtu s3dtu sop114f1.tmon = soa.soon , sop114f1.tmshp# = soa.soshpn , sop114f1.tmcust = soa.socust , soa.soon = s3o.s3on , sop114f1.tmon = s3o.s3on , soa.socust = s3o.s3cust , sop114f1.tmcust = s3o.s3cust , soa.soshpn = s3o.s3shpn , sop114f1.tmon = s3dtu.s3dton , sop114f1.tmshp# = s3dtu.s3dtshp# group tmon, tmcpo#, tmrqd, s3itno, s3orqt, tmcust, tmname, s3dtsto, tmschid, s3dtadt
i imagine need subquery this, lost, on how this. apologize, query created in "showcase" uses clauses extensively instead of joins.
Comments
Post a Comment