I have a table with customers (fixed number of customers). These customers purchages goods either online or by visiting the shop.
I want to get the list of all the customers with an additional column stating oredered. Fill the column with (If cutomer ordered online) 1 or (if not oredered online) 0.
Each customer can have more orders (via telefone, via email or via visiting the store). the column online order has X
mark if ordered online for that partcular order the customer.
I have orders table and customers table, identifier is the customer ID. In orders table there is a column that is marked with X
. I need to convert the X to 1
and the other with 0
somehow.
My table looks like:
Customer ID| Order ID| Order
1 |1 | -
1 |2 |
1 |3 |X
2 |4 | -
2 |5 | -
2 |6 | -
3 |7 |X
3 |8 |X
3 |9 |X
Resulted table should look like:
|Customer ID|Oredered Online
|Customer1 |1
|Customer2 |0
|Customer3 |1
I dont know exactly the conditions work, i tried CASE, WHEN THEN, did'nt work as i wanted.
Thank you!