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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 query select
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

8 Posts

Posted - 03/12/2014 :  14:23:24  Show Profile  Reply with Quote
w have 2 table :item and transaction
item transaction
id name period id area amount
1 clothes 2011-10 1 north 1200
2 bike 2011-11 1 west 1300
3 car 2011-11 2 east 300

period id amount
2011-10 1 1200
2011-10 2 0
2011-10 3 0
2011-11 1 1300
2011-11 2 300
2011-11 3 0

i have tried to create query for get a data like a table result above
but still not macth
my query
select b.period,,b.amount from transaction b left join item a on order by date

please help for this.thanks

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 03/12/2014 :  16:41:01  Show Profile  Reply with Quote
Create a calendar table that has all the periods that you want to show in the output data. Then left join your two tables to that new table.

What is the data type of the period column in your existing tables?
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.72 seconds. Powered By: Snitz Forums 2000