Forum Replies Created

Viewing 15 posts - 3,661 through 3,675 (of 4,087 total)

  • RE: pretty ugly, mostly not-really-set-based problem to solve

    If you use the grouping() functions, you can do this without the temp table.

    SELECT

    CASE WHEN Grouping(ID2) = 1 THEN ID END AS ID

    , CASE WHEN Grouping(Val) =...

  • RE: Horrible Nested Queries

    It's probably easier to change your aggregate to a distinct count.

    Count(DISTINCT Staff_Seq_Num)

    You may also need to use another field if that doesn't give you the correct counts.

    Drew

  • RE: Finding and recording offset values using SQL

    Rob Titerle (8/4/2011)


    This is a fundamentally simple problem, but I don't see what is likely the obvious solution. Any help pointing out the obvious to me would be greatly...

  • RE: XML Query Attributes

    I assume that you actually want where the name attribute is "FirstAttributeName" since there is nothing named "FirstAttribute" in your sample.

    This should give you what you want.

    SELECT per.value('(Data/item[@name="FirstAttributeName"])[1]', 'varchar(50)') AS...

  • RE: Adding a Decimal Value to a DateDiff Statement

    DateDiff will always produce an integer result. You need to move your addition outside of the DateDiff function.

    CASE Type WHEN 'HALF' THEN DATEDIFF (d, StartDate, EndDate) + 0.5

    You're thinking...

  • RE: Dimension/Fact table design books

    Sqlraider (7/27/2011)


    Any chance you could translate those pieces into FACT & DIM or give me a starting point?

    In its most basic form, think of it as AGGREGATE FACT BY DIMENSION....

  • RE: How to transpose reccords in SQl Server 2005

    In most cases where there is no obvious aggregation, you'll want to use Min() or Max(). If there is only one value corresponding to each pivot value, they'll give...

  • RE: Adding a Decimal Value to a DateDiff Statement

    Jeff Moden (7/26/2011)


    DATEDIFF doesn't work the way most people think. It works on the borders of days (ie: midnight).

    I would amend this to say that it works on the...

  • RE: Google Analytics XML file to SQL2005 table

    mfink (7/26/2011)


    A completed version of the problem and solution

    SELECT

    c.value('(//AnalyticsReport/Report/Title/ProfileName)[1]','varchar(100)') as WebPage,

    c.value('(PrimaryKey)[1]', 'varchar(30)') AS Date

    , c.value('(DrilldownId)[2]', 'varchar(25)') AS Region

    , c.value('(Cell/Content/Value)[1]', 'int') AS Counts

    FROM @x.nodes('/AnalyticsReport/Report/Table/Row')...

  • RE: Delete data older than 30 days, char to datatime conversion.

    All of the valid formats require some kind of separator between the various components except for 112 which doesn't include the time components. Your conversion is failing, because your...

  • RE: 3 views similar data into 1 report

    Since we don't have information on your base tables or your views, it's hard to say what the best approach might be. If your views are simple selects on...

  • RE: Google Analytics XML file to SQL2005 table

    If you're going to be working with XML, you need to learn XPath. There is a tutorial at W3Schools http://www.w3schools.com/xpath/. XPath is very easy.

    Drew

  • RE: Google Analytics XML file to SQL2005 table

    mfink (7/25/2011)


    AnalyticsReport('(ProfileName)[0]','varchar(100)') as WebPage1,

    c.profileName('(ProfileName)[0]','varchar(100)') as WebPage1,

    c.value('(ProfileName)[0]','varchar(100)') as WebPage2,

    none of these am I headed in the right direction?

    What's the current node?

    What's the relative path from the current node to ProfileName?

    You're using...

  • RE: Google Analytics XML file to SQL2005 table

    mfink (7/25/2011)


    How would I add the profileName to that select?

    See if you can figure it out for yourself. You just need to determine the relative path from your current...

  • RE: Google Analytics XML file to SQL2005 table

    mfink (7/25/2011)


    Msg 9438, Level 16, State 1, Line 2

    XML parsing: line 2, character 6, text/xmldecl not at the beginning of input

    You can't have any whitespace before the <?xml version="1.0" ?>.

    Drew

Viewing 15 posts - 3,661 through 3,675 (of 4,087 total)