Forum Replies Created

Viewing 15 posts - 13,246 through 13,260 (of 13,876 total)

  • RE: Query Performance

    Try running SQL Profiler when you run the query - you should be able to get exact execution times that way.

  • RE: SQL sub-query problem

    Sticking with Northwind, is this roughly where you're heading?

    select sum(t1.Count1), sum(t1.Count2) from

    (select employeeid,

    Count1 = (

    case

     when Count(EmployeeID) < 100 then Count(EmployeeID)

     else 0

    end

    ),

    Count2 = (

    case

     when Count(EmployeeID) >= 100...

  • RE: SQL sub-query problem

    OK, here's an example.  Try running against the Northwind database.

    select employeeid,

    Count1 = (

    case

     when Count(EmployeeID) < 100 then Count(EmployeeID)

     else 0

    end

    ),

    Count2 = (

    case

     when Count(EmployeeID) >= 100 then Count(EmployeeID)

     else 0

    end

    )

    from...

  • RE: SQL sub-query problem

    OK - I see now what you're trying to do.

    One idea I've had, which I've not tested, is for you to have a single subquery containing two counts

    select studentid, count1,...

  • RE: SQL sub-query problem

    If you put the COUNTs in the subqueries, I think that this will work:

    SELECT t1.TotalRows, t2.TotalRows FROM

    (SELECT count(StudentID) TotalRows

    FROM Attendance

    WHERE ClassId=1 and Month(Date)=11 and status=0

    GROUP BY studentID

    HAVING...

  • RE: Creating "% out of total" colu,m

    Any time, glad to help.

  • RE: Creating "% out of total" colu,m

    You appear to have ditched my CASE statement, for some reason!  That's the way to get zero returned if B is 'no'.

    Also, you should prefix your date column selections (tab1.date,...

  • RE: Creating "% out of total" colu,m

    I actually typed in your data to test my query, so it should be right

    Please post the actual SQL that is generating the...

  • RE: Creating "% out of total" colu,m

    This should do it - uses a co-related subquery:

    select t.b, t.d, t.c,

    Calc = case t.b

    when 'yes' then t.c / (select cast(sum(t2.c) as decimal(19)) from A t2 where t2.d =...

  • RE: Error "Invalid Connection. ConnectionOpen (Invalid Instance())

    Have you tried a full reboot of the server?

    Has anything been installed on the server recently?

  • RE: SQL Scripts Help

    Assuming that's all you want ...

    SELECT MIN([DATE]) FROM STOCK_MOVEMENT_HISTORY

    If you actually want more than that, please post an example of your required results.

  • RE: Internal SQL Server error.(42000,8624)

    Check this article & see whether it's relevant:

    http://support.microsoft.com/kb/885442

  • RE: GROUP BY question

    No it doesn't.

    From BOL:

    COUNT(*) returns the number of items in a group, including NULL values and duplicates.

    COUNT(ALL expression) evaluates expression for each row in a group and returns the number...

  • RE: Internal SQL Server error.(42000,8624)

    This is a weird one.  Have you run dbcc checkdb?

    Also, if you run the statement directly through QA (rather than as part of a stored proc), do you get the...

  • RE: GROUP BY question

    As soon as you put a count() in your query, SQL Server assumes that you are attempting to summarise your data in some way.  In particular, it assumes that you...

Viewing 15 posts - 13,246 through 13,260 (of 13,876 total)