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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Join a Table to Itsself?

Author  Topic 

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2011-02-02 : 10:51:13
hi experts,

I have 3 types of records, all in the same table:

RecType Date Other Columns
25 2/2/2011

59 2/2/2011
59 2/2/2011

148 2/2/2011

I need to select all records that have the same Date so I can write a single consolidated record to another table for reporting purposes.

I'm not sure if a Cross Join is needed, I've never used cross-join.

Thanks for any tips.
John




webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-02 : 11:28:21
Not sure what your needed output in relation to the sample data is...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2011-02-02 : 11:57:48
webfred,

This table I'm querying contains infor about transaction deadlocks.

The '25' record type contains a Duration value, the 148 rec has the SQL stmt and the 50 record has the ObjectID (which I can use to retrieve the Table name from sys.objects)

So my goal is to create a single record in another table that contains those columns that I need. A single reocrd that shows everything I need to know about that deadlock instance.

I hope I have explained what I'm hoping to do.

Thanks, John
Go to Top of Page

ZZartin
Starting Member

30 Posts

Posted - 2011-02-02 : 12:28:33
you should be able to use the same table multiple times in a single query by naming it, try something like SELECT [columns] FROM Table a, Table b, Table c WHERE [whatever criteria you need]
Go to Top of Page
   

- Advertisement -