find_locations_with_available_items_given_branch_code_num

Custom SQL query (hide)

with location_data as (
  select
    i.location_code,
    count(*) as count_available_items
  from
    item as i 
  where
    i.item_status_code = '-'
    AND i.location_code in (
      select
        code
      from
        location as loc
      where
        loc.branch_code_num = :branch_code_num
    )
  group by
    i.location_code
)
select
  location_code,
  (
    select
      ln.name
    from
      location as loc
      left outer join location_name as ln on ln.location_id = loc.id
    where
      loc.code = d.location_code
  ) as location_name,
  count_available_items
  from
    location_data as d

Query parameters

Edit SQL

0 results