SQL Server: Ordering rows before select -


My head around this one can not be enough, I have to select all the records where the supply is about to end The order was ordered. For example, if a person orders a supply of 30 days to 1/1/2014 and is ordered to supply 30 days before 25% of the supply, then it is considered a duplicate order. Do I now select a Nest:

  Use duplicates_2014 to check order from petsnmore * Where (selection exists * from command to ou where a.ID = b.ID and a. B.dos between claim_num = b.claim_num and a.service_id = b.service_id and a.visit_num = b.visit_num and a.dos and dateADD (day, floor (a.days_supply * .25), a.dos))   

Rows returned are not expected and I think the reason for this is that the rows have not been compared in the proper order. I need this:

  claim_num asc, service_id asc, dos asc, order_num order by DESC   

The curriculum only commands the SQL Server in the outside world By choosing to choose. I know that any ideas should be a better way?

Thanks

You can use a table variable (or a temporary table If you want to ask your results more than once) then to sort your data and then use that table to get back to your original question and see where you can go from there.

  @duplicateorders table (& lt; order table & gt regions;) Announcement! Choose * from order b @duplicateorders in a.ID = b.ID and a.claim_num = b.claim_num and a .service_id = b.service_id and a.visit_num = b.visit_num and a.dos and dateADD (day, floor) (A.days_supply * .25), a.dos) claim_num asc order, service_id asc, dos between b.dos asc, visit_num, dex,    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -