Skip to content

Join query with null values

I have this query SELECT * FROM orders, products, suppliers WHERE product_id=products.id AND `geleverd` = 1 AND supplier_id=suppliers.id It works fine except that when the suppliers_id is …

Can you join by columns with aggregate functions?

Is it possible to join by aggregate functions? Let’s say we have in the main query: Select MIN(id) as MINID, product AS PRODUCT, SUB.produkt_name, SUB.product_type FROM log_table GROUP BY PRODUCT, …

How to Join three tables properly

The main table has 4 columns: User Activity Table userActivityId userId therapistId activityId 1 1 1 1 Each of these columns is a table and these values are all …

check if row exists with specific value

I have 2 tables task and taskattributes. There is a linking between 2 tables with taskid. Each taskid has multiple attributes represented by key,value. I would like to find out if specific key exists …

Avoid NULL value in CASE SQL SERVER

How to avoid NULL values in CASE and SUM by P.Id. Problem is that i have more than one DPB.ProductTypeId in DPB table SELECT P.[Id], CASE WHEN DPB.ProductTypeId = 1 THEN SUM(DPB….