Forum Replies Created

Viewing 15 posts - 1,786 through 1,800 (of 2,171 total)

  • RE: Minimum of top two values

    select *

    from @mytable

    where row_number() over (partition by itemname order by itemvalue desc) = 2

    order by itemname

     

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Minimum of top two values

    Run this

    select  d.itemname,

      max(x.itemno) as itemno,

      d.qwerty

    from  ( 

       select t1.itemname,

        (select min(itemvalue) from (select top 2 t2.itemvalue from @mytable as t2 where t2.itemname = t1.itemname order by t2.itemvalue desc) as d) as qwerty

       from @mytable as t1

     &nbsp


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: How do I aggregate this table?

    Answered here

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=77856

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Each GROUP BY expression must contain at least one column that is not

    update  c

    set  c.col3 = d.qwerty

    from  tableA as c

    inner join (

       select  a.col2,

         count(b.idcol) as qwerty

       from  tableB as b

       inner join tableA as a on a.idcol = b.idcol

       group by a.col2

     &nbsp as d on c.col2 =...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: CASE WHEN

    SELECT NULLIF(Col001, 'NULL') AS NewCol1,

           NULLIF(Col002, 'NULL') AS NewCol2

    FROM   <YourTableNameHere>


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: check my function

    set @return = isnull(@return, 0) + 1


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: data types default values

    You want just the date?

    SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: union versus where condition with "OR" operator

    Using UNION ALL can potentially lead to duplicates, if both fieldA and fieldB contains the text "my".

    Replace UNION ALL with UNION only to get correct result. But then the query...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Combine 2 queries with different where clause

    Also asked and answered here

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74180

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Reverse Insert

    Something like

    INSERT Target

    SELECT PIN, <someothercolumns> FROM Source

    UNION ALL

    SELECT PIN, <someothercolumns> FROM Source

    UNION ALL

    SELECT PIN, <someothercolumns> FROM Source


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: OPENROWSET and EXCEL

    http://www.connectionstrings.com

    Also, there are massive information here

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: intested of "INTERSECT"

    Also asked and answered here

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73899

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: best possibilities

    Fast generic solution posted here

    http://www.sqlteam.com/forums/topic.asp?whichpage=2&TOPIC_ID=73610&#264068

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: best possibilities

    Ok, now I follow you!

     


    N 56°04'39.16"
    E 12°55'05.25"

  • Viewing 15 posts - 1,786 through 1,800 (of 2,171 total)