Home Forums SQL Server 2008 SQL Server Newbies Display two fields of two UNRELATED tables WITHOUT crossjoin RE: Display two fields of two UNRELATED tables WITHOUT crossjoin

  • GilaMonster - Tuesday, February 5, 2013 12:41 PM

    In this particular case, since you want the two counts...SELECT q1, q2 FROM(SELECT Count(a.PK) as q1 FROM Table1 as a) t1, (SELECT Count(b.PK) as q2 FROM Table2 as b) t2Only in this case though. In general the question can't be answered. How can you meaningfully join two completely unrelated tables and have the columns related to each other? If they are completely unrelated, then they probably shouldn't even be in the same query

    Thank you.  Actually this was exactly what I needed to do. In my particular case, I simply needed to return two column summations from Table 1, and the row count from Table 2.  The values are all related in a business sense, but not in any direct way in the schema.

      SELECT q1, q2, q3 FROM (SELECT SUM(t.ext_reg_deny) as q1, SUM(t.ext_reg_err) as q2 FROM traffic t) t1, (SELECT COUNT(r.id) as q3 FROM registration r) t2;