خرید بک لینک

Vote count: 0

I've got a problem with MSsql.

My product table looks like this

id_product   |   product_count  |  product_name  
1            |   10             |  name1
2            |   20             |  name2
3            |   20             |  name3
4            |   52             |  name4
5            |   30             |  name5
6            |   50             |  name6

And i want to do query that result will be

 product_group_name   |   product_group_name | product_group_name |...more groups
 30(sum)              |   72(sum)            | 50(sum)            |...more values

where group will be id_product like(1,2 OR 3,4 OR 1,4,5) and group name will be alias

here is sql code to make single column

SELECT 
    cast(SUM( product.product_count) as float) as  group_name
FROM    
        product
WHERE 
     product.id_product in (608,913,528,529,920,406,407,408,912,919,918,917,924,926,925)

and result of this query is:

| group_name |
| 200        |

Is it possible to add more columns with group names? it is important to be a columns not rows.

asked 21 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 14 تير 1395 ساعت: 16:29

صفحه بندی