Forum Replies Created

Viewing 15 posts - 2,146 through 2,160 (of 2,169 total)

  • RE: How to use relative path in BULK INSERT

    Try calling API

     

    ExpandEnvironmentVariable

  • RE: Excel & OpenRowset

    Connection to Excel using Jet Engine

    To connect to Excel, one can use OleDb objects that will treat Excel as a database, and then the required information can be easily fetched...

  • RE: Two SELECT...GROUP BY queries into one query

    Hi Joe!

    I have read your books on SQL for smarties over and over again! Never thought I met you online.

     

    Sorry to say there is a glitch in your query.

    Suppose...

  • RE: Get the max out of a series of periods

    • Are your dates stored as datetimes/smalldatetimes or varchar?
    • Is @FromDate smaller/earlier/older than @ToDate?

    I run the queries against a test set of 10 000 rows of DATETIME and INT and they tooks...

  • RE: Get the max out of a series of periods

    This code should be used for fixed daterange (always x virtual days in the calendar for the range)

    DECLARE  @FromDate DATETIME,

             @ToDate DATETIME,

             @DateRange INT,

             @SKU VARCHAR(1)

    May 19, 2006 at 8:35 am

    #639017

  • RE: Get the max out of a series of periods

    Should the range be as followed?

     

    01-01-2006..............A.........20

    01-01-2006..............B.........20

    02-01-2006..............A.........30

    02-01-2006..............A.........40

    02-01-2006..............B.........10

    04-01-2006..............A.........20

    04-01-2006..............A.........50

    05-01-2006..............A.........40

    05-01-2006..............A.........10

    Now suppose my daterange is 2 days, so in the above table i need to get the total for :

    01-01-2006 - 02-01-2006 (2days) Sum for...

  • RE: Get the max out of a series of periods

    Here we go again...

    DECLARE  @FromDate DATETIME,

             @ToDate DATETIME,

             @DateRange INT,

             @SKU VARCHAR(1)

    SELECT   @FromDate = '2004-01-15',-- This is the starting date in the range

             @ToDate...

  • RE: Get the max out of a series of periods

    The data is not stored as a date range. See example.

    "I have a table with the following data (date, value)"

  • RE: Get the max out of a series of periods

    Or more specific

    DECLARE  @FromDate DATETIME,

             @ToDate DATETIME,

             @DateRange INT

    SELECT   @FromDate = '2004-01-15',-- This is the starting date in the range

             @ToDate = '2008-02-20',-- This...

  • RE: Get the max out of a series of periods

    You mean like this?

     

    DECLARE  @FromDate DATETIME,

             @ToDate DATETIME,

             @DateRange INT

    SELECT   @FromDate = '2004-01-15',

             @ToDate = '2008-02-20',

             @DateRange = 20

    SELECT   MIN(Date)...

  • RE: Distinct vs Group By

    The greatest factor is proper indexes.

    I run the two questions against our production server with 90+ million rows.

    DISTINCT took 66 seconds.

    GROUP BY took 8 seconds.

     

  • RE: Make a Crosstab relational?!

    Based on the original posting, the query would be someting like

    SELECT AggregateGroup, 1 FiscalMonth, Jan Amount FROM MySourceTable

    UNION ALL

    SELECT AggregateGroup, 2, Feb FROM MySourceTable

    UNION ALL

    SELECT AggregateGroup, 3, Mar FROM MySourceTable

    UNION ALL

    SELECT AggregateGroup, 4, Apr FROM MySourceTable

    UNION...

  • RE: Two SELECT...GROUP BY queries into one query

    Here is the real query with some optimization techniques...

    SELECT   SUM(CASE WHEN DT.type = 'r' THEN DT.Items ELSE 0 END) Registrations,

             SUM(CASE WHEN DT.type = 'c' THEN DT.Items ELSE 0...

  • RE: GEOCODE Street corner --- brain stopped

    Heureka! I've found it!

    Here is a "one query"-solution...

    SELECT DISTINCT CONVERT(SMALLMONEY, x1 + ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) * (x2...

  • RE: GEOCODE Street corner --- brain stopped

    The result of your supplied geodata is:

    (27.9272; -26.1670)

    (27.9290; -26.1677)

    (27.9291; -26.1677)

    (27.9292; -26.1678)

    (27.9293; -26.1678)

    (27.9300; -26.1673)

    There are six intersections within the supplied geodata.

Viewing 15 posts - 2,146 through 2,160 (of 2,169 total)