behzad razzaqi
behzad razzaqi

Reputation: 275

How can i implement this select query in SQL Server?

I'm a new to SQL Server, and have to import this data into a table:

enter image description here

I want to show me this data:

942,4600
952,4000

For that purpose I wrote this SQL statement:

SELECT 
    SUM(SQ.[price])
FROM
    (SELECT DISTINCT 
         [sycle] as TRACK, [price] 
     FROM 
         [ClubEatc].[dbo].[testTABLE]) SQ

That query sums all sycle prices, but I want sum per sycle. How can I implement this? Thanks.

Upvotes: 0

Views: 41

Answers (1)

Just Group by SQ.sycle:

It will set group of each unique sycle and do some of it's price.

SELECT 
   SQ.sycle,
   SUM(SQ.[price]) AS Price
FROM TableName SQ
Group By SQ.sycle

Upvotes: 1

Related Questions