database - Repeated elements counting for Sql datatables queries -


i have 2 tables: order table , orderdetails table. have written inner join:

  select order.id   order   inner join orderdetails     on order.id=orderdetails.id 

i have got output as:

   id   100   100   100   101   101 

from above data, want count of each record output as:

  id  count   100  3   101  2 

how this?

select orderid , count(*) [count] orderdetials group orderid  

orderid foreing key column referencing order.id column of order table

if orderdetails.id references order.id column query.

select id , count(*) [count] orderdetials group id 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -