Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 hi

Author  Topic 

raj123
Starting Member

1 Post

Posted - 2007-11-10 : 21:01:28
hii am new to this sql server , i got a query which is very small..

how can we get the summary sales by year

thanks ,
Raj

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-10 : 21:16:06
You must be kidding right?

With no sample data, column names, table names or actual desired results, all I can suggest is that you summarize the sales and group by the Year.

Standard syntax might look like

SELECT Year(sale_Date) as [Year],SUM(sales) as [Sum of Sales]
FROM SalesTable
Group by Year(Sale_Date)
ORDER BY Year(Sale_Date) asc
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-12 : 02:17:30
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-12 : 04:23:03
to get the summary of sales yearwise its quite obvious u would like to do some manipulation of data so go through the group by clause first to use aggregate functions with.

look out for the links
http://www.sql-server-performance.com/articles/per/art_aggregate_functions_p1.aspx
http://www.sqlteam.com/article/how-to-use-group-by-in-sql-server
http://www.microsoft.com/learning/syllabi/en-us/2071bfinal.mspx

and if not clear give a sample of your input and output that you want exactly

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA

######################
IMPOSSIBLE = I+M+POSSIBLE
Go to Top of Page
   

- Advertisement -