user6000503
user6000503

Reputation:

SQL Server 2012 select sum of multiple id

For example, I have a device ID of "001" each device ID has a column called total I want to retrieve only the SUM total of each device Id. How to do this please ?

SELECT
    SUM(TicketSales.TotalPrice) AS expr1
FROM 
    dbo.TicketSales,dbo.[Transaction]
WHERE 
    TicketSales.DeviceID = 'mapa001'
    AND SUM(TicketSales.TotalPrice) AS expr2
 FROM 
     dbo.TicketSales ,dbo.[Transaction]
 WHERE 
     TicketSales.DeviceID = 'mapa002'

Upvotes: 1

Views: 34

Answers (1)

user3623480
user3623480

Reputation:

Try this, but read some sql tutorials, these are the basics:

SELECT SUM(TicketSales.TotalPrice) AS expr1
FROM dbo.TicketSales
GROUP BY TicketSales.DeviceID

Upvotes: 1

Related Questions