sql - Select subset from subset -


data has 1 table 2 relevant fields:

  • ordernumber
  • productid

how structure sql find :-

 select ordernumber productid in (a,b)     now, on subset, select productid in (a,b,c,d,e)      show customername, ordernumber, productid, productprice 

goal find orders contain 2 specific products, measure sales of 3 specific products related a,b.

i'm not sure want, take stab.

this show details of orders 1 of 5 product id's

 select customername, ordernumber, productid, productprice  yourtable  productid in ('a','b','c','d','e') 

this count orders you

 select productid, count(*) count  yourtable  productid in ('a','b','c','d','e')  group productid 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -