I have one scenario where I have to send data which customer handling there own area in excel not other areas data in Data-driven subscription(DDS).
ID Name Data(rows) email
1 A 10 A@gmail.com
2 B 4 B@gmail.com
3 A 6 A@gmail.com
4 B 5 B@gmail.com
5 C 4 C@gmail.com
In the above example IF DDS is configured for A, it should go 16 records and for B, It should go 9 records. For C, It will be 4 records. But for me, it was going all records. Can anyone tell me
You can try to use SUM
and group by
CREATE TABLE t(
Name VARCHAR(50),
Data INT,
email VARCHAR(50)
);
INSERT INTO T VALUES ('A',10,'A@gmail.com');
INSERT INTO T VALUES ('B',4 ,'B@gmail.com');
INSERT INTO T VALUES ('A',6 ,'A@gmail.com');
INSERT INTO T VALUES ('B',5 ,'B@gmail.com');
INSERT INTO T VALUES ('C',4 ,'C@gmail.com');
Query 1 :
SELECT Name,SUM(Data) records
FROM T
GROUP BY Name
Results :
| Name | records |
|------|---------|
| A | 16 |
| B | 9 |
| C | 4 |
Try below query: using group by
select name, email, sum(data) as records from tablename
group by name, email
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.