Results 1 to 4 of 4

Thread: query

  1. #1
    Join Date
    Feb 2009
    Posts
    2

    Unanswered: query

    query of pulling some distinct data from two table into new table

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT DISTINCT 
           t1.foo
         , t2.bar 
      INTO newtable
      FROM table1 AS t1
    INNER
      JOIN table2 AS t2
        ON t2.fkey = t1.pkey
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2008
    Posts
    135
    try like this too
    select col,col into #Temp
    (
    SELECT row_number()OVER (partition by t1.col , t2.col order by t1.col1) as rid,
    t1.col
    , t2.col
    FROM table1 AS t1
    INNER
    JOIN table2 AS t2
    ON t2.fkey = t1.pkey ) s
    where s.rid = 1

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bklr
    select col,col ...
    that's not gonna work the way you think it's gonna work
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •