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.
| Author |
Topic |
|
Alemao
Starting Member
3 Posts |
Posted - 2007-01-24 : 04:47:37
|
| Good day Sql YodasI have two tables store_information and sales_information as shown below how can I write a join query so that I can get results based on Sales_information table structure like so :Table New_InformationS/N store_name Expenditure Date Type1 Los Angeles $1500 Jan-05-1999 Cash2 San Diego $250 Jan-07-1999 Cheque3 Los Angeles $300 Jan-08-1999 Cheque4 Boston $700 Jan-08-1999 Cash Below are the two tablesTable Store_InformationS/N store_name Expenditure Date1 Los Angeles $1500 Jan-05-19992 San Diego $250 Jan-07-19993 Los Angeles $300 Jan-08-19994 Boston $700 Jan-08-1999 Table Sales_InformationS/N store_name Sales Type1 Los Angeles $1500 Cash2 San Diego $250 Cheque3 Los Angeles $300 Cheque4 Boston $700 Cash5 New York $900 Cheque6 Chicago $300 Cheque7 Atlanta $250 Cash |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-24 : 05:07:38
|
[code]select a.sn, a.store_name, a.expenditure, a.date, b.typefrom Store_Information a inner join Sales_Information b on a.store_name = b.store_name[/code] KH |
 |
|
|
Alemao
Starting Member
3 Posts |
Posted - 2007-01-24 : 06:09:08
|
| Thanks for ur response Khtan I forgot to mention to you that store_ information and sales_information are views after use ur queries what I got are duplicated values |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-24 : 06:29:52
|
try this...select a.sn, a.store_name, a.expenditure, a.date, b.typefrom Store_Information a inner join Sales_Information b on a.store_name = b.store_name and a.sno = b.sno KH |
 |
|
|
Alemao
Starting Member
3 Posts |
Posted - 2007-01-24 : 06:56:29
|
| Khtan, youre a great guy and a smart one you just resolve 3 days of sleepless night you resolve this sub queries issue. I really appreciate your patience and support.I am so far away if not I will give you my pretty sister for keeps.Everyone on the Forum Khtan ROCKS !!!!!!!!! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-24 : 18:12:28
|
| Only 3 days?Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|