Guest User

Untitled

a guest
Jun 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. SELECT RES.* FROM (
  2. SELECT SR.sr_id, TSIV.sr_item_id, TSIV.rank, TSIV.entry, U.description AS unit_desc, CT.description AS ct_desc, SR.appt_start, CA.site_city, CA.site_state,
  3. dbo.conditional_flat_rate_description(TSIV.entry, TSIV.cost_under_max_rate, TSIV.cost_over_max_rate, TSIV.cost_min_units, TSIV.cost_max_units, TSIV.cost_description, TSIV.cost_show_math, NULL) AS 'statement_description',
  4. round(dbo.conditional_flat_rate1(TSIV.entry, TSIV.cost_under_max_rate, TSIV.cost_over_max_rate, TSIV.cost_min_units, TSIV.cost_max_units, TSIV.statement_description, TSIV.statement_amount), 2) AS 'statement_amount' FROM sr SR
  5. INNER JOIN ctn CTN ON SR.ctn_id = CTN.ctn_id
  6. INNER JOIN ctn_address CA ON CTN.ctn_id = CA.ctn_id
  7. INNER JOIN ctn_type CT ON CTN.ctn_type_id = CT.ctn_type_id
  8. LEFT JOIN total_sr_items_vw TSIV ON SR.sr_id = TSIV.sr_id
  9. LEFT JOIN units U ON TSIV.unit_id = U.unit_id
  10. LEFT JOIN cost_rates CR ON TSIV.cost_rate_id = CR.cost_rate_id
  11. WHERE SR.sr_id IN($srIds)
  12. )RES
  13.  
  14. WHERE RES.statement_amount != 0
Add Comment
Please, Sign In to add comment