Note that there are some explanatory texts on larger screens.

plurals
  1. POOracle SQL Distinct Clause not presenting distinct values
    primarykey
    data
    text
    <p>I have a script when I'm trying to select locations in an inventory where quantity of said location is &lt;= 5. The query is complete, now I'm trying to do some fine tuning, and what I'm running into now is when I use the distinct clause I am still receiving duplicate records in the same column. I do know the column next to the first are unique, but I thought distinguishing distinct and one column would roll over to next related to said column.</p> <p>Here is my code:</p> <pre><code>select DISTINCT bin.scannable_id as bin, bi.bin_id as case1, pallet.scannable_id as pallet, -- bi.isbn as fcsku, nvl(fs.asin,bi.isbn) as asin, sum(bi.quantity) as quantity, pallet.creation_date as received_date from containers bin join containers pallet on pallet.containing_container_id = bin.container_id join containers case on case.containing_container_id = pallet.container_id join bin_items bi on bi.container_id = case.container_id left join fcskus fs on fs.fcsku = bi.isbn where bin.scannable_id like 'R-1-T%' and bi.quantity &lt;= '5' group by bin.scannable_id, pallet.scannable_id, bi.bin_id, bi.owner,bi.isbn,nvl(fs.asin,bi.isbn), pallet.creation_date order by sum(bi.quantity); </code></pre> <p>My output, which is obviously showing duplicate records in the scannable_id column: <img src="https://i.stack.imgur.com/9VDpg.jpg" alt="enter image description here"></p> <p><strong>Correct Formatting Thanks to conrad.</strong></p> <pre><code> select DISTINCT bin.scannable_id as bin, pallet.scannable_id as pallet, nvl(fs.asin,bi.isbn) as asin, sum(bi.quantity) as quantity from containers bin join containers pallet on pallet.containing_container_id = bin.container_id join containers case on case.containing_container_id = pallet.container_id join bin_items bi on bi.container_id = case.container_id left join fcskus fs on fs.fcsku = bi.isbn where bin.scannable_id like 'R-1-T%' having sum(bi.quantity) &lt;= '5' group by bin.scannable_id, pallet.scannable_id, nvl(fs.asin,bi.isbn), bi.quantity order by sum(bi.quantity); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload