Forum Replies Created

Viewing 9 posts - 16 through 25 (of 25 total)

  • RE: Interesting Query Challenge

    SELECT p.PeopleID, p.ProfileID

    FROM Profiles p JOIN

    (SELECT PeopleID, MAX(Updated) LastUpdated

    FROM Profiles

    GROUP BY PeopleID) x ON p.PeopleID = x.PeopleID AND p.Updated = x.LastUpdated

  • RE: Baffled by query--complete

    SELECT g.MarketingGroup, SUM(s.DailySales) [Year-To-Date],

    SUM(CASE WHEN s.Day >= '20070201' AND s.Day < '20070301' THEN s.DailySales END) [Month-To-Date]

    FROM dbo.Sales s JOIN

    (SELECT 'Kiwi' ProduceItem, 'FRUIT' MarketingGroup

    UNION ALL SELECT 'Apricot', 'FRUIT'

    UNION ALL...

  • RE: multi level grouping ?

    SELECT s.#District, s.StoreId #Store, SUM(i.InvoiceAmount) Total#Invoices, SUM(i.ItemsSold) TotalItems,

    CONVERT(char(7),i.InvoiceDate,120) YearMonth --, CONVERT(char(8),STUFF(InvoiceDate,4,3,''),101) MonthYear

    FROM #Store s JOIN #Invoices i ON s.StoreId = i.StoreId

    GROUP BY CONVERT(char(7),i.InvoiceDate,120), s.#District, s.StoreId--, CONVERT(char(8),STUFF(InvoiceDate,4,3,''),101)

    Problem with your MonthYear format...

  • RE: converting StartTime to Military time format

    declare @starttime varchar(10), @stoptime int

    set @starttime = '16:30'

    set @stoptime = 1249

    select duration = @stoptime - datediff(n,0,@starttime)

  • RE: Finding first number from a string

    select left(c1,patindex('%[^0-9]%',c1)-1)

    from test

  • RE: How Do I Zero-Fill an Int when converted to Char?

    CONVERT(char(5),@dt,120)+RIGHT('0'+DATENAME(ww,@dt),2)

  • RE: Format Number

    select stuff(convert(char(22),round(cast(800.00070474058253 as float),6),2),11,7,'')

  • RE: Trouble with ALTER PROC

    Could just read "Deferred Name Resolution and Recompilation" in BOL.

    There is problem with instantiating local variable as here. If table has more then 1 row, value may be unexpected.

Viewing 9 posts - 16 through 25 (of 25 total)