Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

sum of columns based on new group

$
0
0

Below is my database table
Product Id    IsPrimary    Quantity
P001    1    
P001.1    0    2
P001.2    0    4
P001.3    0    5
P002    1    
P002.1    0    6
P002.2    0    7
P002.3    0    9
P002.4    0    10
P002.5    0    11
        
Need the query for result each group shows multiplied value of group quantity and last row of the group is shown with NULL
        
Product Id    SubProduct    Quantity
P001                        40
P001                P001.3    NULL
P002                         41580
P002                   P002.5    NULL

ShanmugaRaj


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>