Advertisement
agir

SQL to find closest price

Mar 12th, 2018
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. Let(
  2.  
  3. [
  4. table = _FIELDREF_getTO ( DRIVE_COST::ID ; "" ) ;
  5. device = JOBS~::Drive_SourceMediaType ;
  6. capacity = JOBS~::Drive_Capacity ;
  7. drive = Jobs~TargetMediaUsed::Description ;
  8. unit = JOBS~::Drive_CapacityUnits ;
  9. encrypted = 1 ;
  10.  
  11. sql =
  12. "SELECT TOP 1 PRICE
  13. FROM " & table & "
  14. WHERE DEVICETYPE LIKE " & "'" & "%" & device & "%" & "'" & " AND
  15. ENCRYPTED = " & encrypted & "
  16. ORDER BY ABS(CAPACITY - " & capacity & ")";
  17. result = ExecuteSQL ( sql ; ¶ ; "" )
  18. ];
  19.  
  20. "(not to exceed $" & result & " for a " & "capacity" & " " & unit & " " & drive & "drive.)" & ¶ &sql
  21. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement