Forum Replies Created

Viewing 15 posts - 811 through 825 (of 1,248 total)

  • RE: Update within/after Union

    Are you modifying the view or updating the source tables?

    If you're just modifying the results returned in the view, and assuming the the phone column is a varchar the code...

  • RE: How can I pivot results of query?

    Fair enough, I was just wondering if'd missed something 🙂 I think that QUOTENAME is going to be something that will make my life easier though.

  • RE: How can I pivot results of query?

    select yearMonth

    ,BariatricSurgery

    ,BISurgeries

    ,EDTransfersToBI

    ,GYNOncProcedures

    ,GYNOncVisits

    ,InpatientTransfersToBI

    ,OPVisitsByBI

    ,PercentAdmitsFromED

    ,ThoracicSurgery

    from

    (

    select

    YearMonth

    ,metric

    ,data

    from

    dbo.test t

    ) p

    pivot

    (

    max(data)

    for metric

    in (

    BariatricSurgery

    ,BISurgeries

    ,EDTransfersToBI

    ,GYNOncProcedures

    ,GYNOncVisits

    ,InpatientTransfersToBI

    ,OPVisitsByBI

    ,PercentAdmitsFromED

    ,ThoracicSurgery

    )

    ) pvt

    A common or garden pivot will do the same too. As a genuine question on...

  • RE: Struggling with what should be a simple query!

    If you can post some sample data and examples of what you've already tried it'll be easier to see want you want and give you an answer. Have a...

  • RE: SQL Query - Simple Question

    I'm really not sure what you mean by 'doing it in one select'. As far as I can see you'll have to check the preceding row in order to...

  • RE: SQL Query - Simple Question

    This will do what you want but I have assumed that the sample will be taken consistently every minute. If this isn't the case another approach will be needed....

  • RE: Minimal Meetings

    ...it is taken offline i.e. after the stand up.

    When an ex-manager of mine told me they's speak to me offline about something I couldn't help help replying that I wasn't...

  • RE: SQL Date Parameters not working

    In true Columbo fashion, just one more thing...

    You could use

    AverageHolding= avg([Total Clients Value Holding])

    rather than

    AverageHolding=sum([Total Clients Value Holding])

    /(

    Select

    COUNT([Fund Code])

    from

    [#Table]

    Where 1=1

    and [Client No_] = @client

    AND

    [Date]...

  • RE: SQL Date Parameters not working

    You're welcome.

    One other thing, be careful using BETWEEN for date range queries. You're usually better using

    where

    [Date] >= @startdate

    and

    [Date] <= @enddate

    Have a look at this article...

  • RE: SQL Date Parameters not working

    I've had a second look and you need to declare the length of your @client and @fund variables. If you declare them like so

    DECLARE @client as varchar(n)

    DECLARE @StartDate as...

  • RE: SQL Date Parameters not working

    Can you post some sample data please?

    What do you mean by 'not working'? I've taken a guess at what your data looks like and I'm getting a 'divide...

  • RE: Calculate previous Date

    It's a 2008 forum so I took a guess on that 😉

  • RE: Calculate previous Date

    select

    t1.id

    ,t1.timestamp

    ,t2.timestamp

    ,TimeTaken = cast(datediff(second,t1.timestamp,t2.timestamp)/3600 as varchar)+':'

    +right('0'+cast(datediff(second,t1.timestamp,t2.timestamp)/60 %60 as varchar),2)+':'

    +right('0'+cast(datediff(second,t1.timestamp,t2.timestamp) %60 as varchar),2)

    from dbo.runningtime t1

    left join dbo.runningtime t2 on t2.id = t1.id+1

    Here's another attempt.

    @dba-2 From The Cold, I don't mean to...

  • RE: Today's Random Word!

    Stuart Davies (11/25/2014)


    SQLRNNR (11/24/2014)


    Stuart Davies (11/24/2014)


    SQLRNNR (11/24/2014)


    accelerant

    arson

    fun

    house

    Arrest

Viewing 15 posts - 811 through 825 (of 1,248 total)