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 |
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-05-18 : 13:59:20
|
Hi all,Can anyone please help me to write a SP, which includes the following in resultsetThe select statemnet will contain many inner joins, and i am not at all familiar with themDbo.CallCalIDdbo.OrderOrderidcalidorderdatedbo.shippackidorderidshipdateweightcostThe result set should have callid, orderid, packid,weight,cost,orderdate, shipdateDepending on this select statement, i have to add some more conditions in my SPPlease help me in thisThank you all |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-18 : 14:02:49
|
Rather than us doing all of the work, please post what you have tried so far. I'll give you an example:select t1.a, t2.b, t1.c, t3.dfrom table1 t1inner join table2 t2on t1.somecolumn = t2.somecolumninner join table3 t3on t2.someothercolumn = t3.someothercolumnwhere t1.z = 2Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-18 : 14:40:04
|
The best approach to write queries for complex problems is to divide the problem into smaller tasks.1. Put the columns which you want to have as a part of result, in the SELECT part2. See to which tables these columns belong and write down those tables in the FROM clause3. See which columns are common between two tables. Join those tables based on common columns.4. Put additional conditions as a part of WHERE clause.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-05-18 : 15:09:42
|
Thanks to Tara and HarshI am very happy yo say here that, i learned to write queiris using inner join(atleast simple ones)This is only because i followed your example and your explanationThanks a lot |
|
|
|
|
|
|
|