On Fri, Oct 28, 2016 at 12:54 PM, Kim Rose Carlsen <k...@hiper.dk> wrote:

> ​​
>
> CREATE VIEW view_circuit_with_status AS (
>    SELECT r.*,
>           s.circuit_status,
>           s.customer_id AS s_customer_id,
>           p.line_speed,
>           p.customer_id AS p_customer_id
>      FROM view_circuit r
>      JOIN view_circuit_product_main s
>        ON r.circuit_id = s.circuit_id
>       AND r.customer_id IS NOT DISTINCT FROM s.customer_id
>      JOIN view_circuit_product p
>        ON r.circuit_id = p.circuit_id
>       AND r.customer_id IS NOT DISTINCT FROM s.customer_id
> );
>
> SELECT * FROM view_circuit_with_status WHERE customer_id = 1;
>
>
​A couple of random thoughts:

1.
TABLE circuit (circuit_id)
TABLE customer (customer_id)
TABLE circuit_customer (circuit_id, customer_id)

2.
INSERT INTO customer (0, 'Customer number standing in for customer not
assigned');
​
While IS DISTINCT FROM could very well use some more love I surmise the
reason it hasn't gotten it is because most data model set things up so that
it never needs to be used.

​David J.​

Reply via email to