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 |
|
cesi
Starting Member
4 Posts |
Posted - 2008-07-24 : 08:07:30
|
| Hi there,I am new on SQL. Ive been working on basic select statment. Now I just came up a complex query that i dont understand. we can do a subguery in a FROM clause and where clause. what is the mean differences between them? Is the result same or not? How do they work? If you have any idea please let me know. I am getting lost in all those. thanks in advance |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 08:18:52
|
| Yup we can. to explain what they really mean you need to show what snippet you've doubt in. can you please post the code snippet? |
 |
|
|
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-24 : 08:26:31
|
| u'r doubt can be cleared over here..check the linkhttp://articles.techrepublic.com.com/5100-10878_11-6154142.html |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 09:40:11
|
| the first one returns those records from table DWH_SO_PARTSLOGFILE having which has more than 1 records for the combination of fields T2.HOLDING_SIRKET_KOD, T2.BAYI_LOKASYON_KOD, T2.WIPNUMBER, T2.LINENUMBER, T2.DATEINSERTED, T2.LASTLOGMAGIC. However i dont think the T2.LASTLOGMAGIC field should be in group by as it will cause count to always return as one.The second query does exactly the same functionality but only difference is that instead of using IN operator, it just forms a derived table of the subquery and takes join with it to retrieve exactly same result.Please let us know why you have put LASTLOGMAGIC in group by and then again used it for taking the count. |
 |
|
|
cesi
Starting Member
4 Posts |
Posted - 2008-07-24 : 09:54:58
|
| I was just reading an article thats about derived table. You are right they get the same result.thanks mate |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 09:57:11
|
quote: Originally posted by cesi I was just reading an article thats about derived table. You are right they get the same result.thanks mate
But you didnt answer my question. why are you grouping on LASTLOGMAGIC field and taking count on it? |
 |
|
|
cesi
Starting Member
4 Posts |
Posted - 2008-07-24 : 14:34:40
|
Sorry I didnt do this query. Thats why I am trying to understand how those work. but I promise I am going to drop you a line after I ask why is grouped. quote: Originally posted by visakh16
quote: Originally posted by cesi I was just reading an article thats about derived table. You are right they get the same result.thanks mate
But you didnt answer my question. why are you grouping on LASTLOGMAGIC field and taking count on it?
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-25 : 00:30:58
|
quote: Originally posted by cesi Sorry I didnt do this query. Thats why I am trying to understand how those work. but I promise I am going to drop you a line after I ask why is grouped. quote: Originally posted by visakh16
quote: Originally posted by cesi I was just reading an article thats about derived table. You are right they get the same result.thanks mate
But you didnt answer my question. why are you grouping on LASTLOGMAGIC field and taking count on it?
Ok thats fine |
 |
|
|
|
|
|