Forum Replies Created

Viewing 15 posts - 5,896 through 5,910 (of 10,144 total)

  • RE: How do I run subqueries on a dataset?

    Hi Don

    What are you grouping by, in order to use the aggregate operator AVG() in the original query containing this subquery?

  • RE: How do you use a sub query in a join?

    dwilliscp (8/15/2012)


    ... we are guessing that all notifications fall under the highest delivery+item. Still this might be our best shot...

    Of course, unless there's something in Notifications to identify which delivery/item...

  • RE: datetime conversion challenge

    BrainDonor (8/16/2012)


    Although a bit dated (no pun intended) there is an interesting article by Robyn Page for various date and time conversions - http://www.simple-talk.com/sql/learn-sql-server/robyn-pages-sql-server-datetime-workbench/.

    Very good it is too.

    SELECT

    DateFromString,

    DateBackToString...

  • RE: How do you use a sub query in a join?

    Looks like you need to roll up ztb_Carrier_Delivery_Metrics too. Try this:

    SELECT

    d.MAX_Delivery,

    d.MAX_Delivery_Item,

    n.Sales_Order_Number,

    d.REF_DOC,

    n.Notification_cnt

    FROM (

    SELECT

    REF_DOC,

    MAX_Delivery = MAX(Delivery),

    MAX_Delivery_Item = MAX(Delivery_Item)

    FROM ztb_Carrier_Delivery_Metrics

    GROUP BY REF_DOC) d

    INNER JOIN (

    SELECT

    sales_order_number,

    Notification_cnt =...

  • RE: Index Range_scans

    SQLSACT (8/15/2012)


    ...

    Given all of this, is it safe to say that, where possible, make you indexes unique?

    You've seen the benefit that a unique index can bring, but be careful with...

  • RE: Insert records into one table form other table

    This should replace both original queries:

    INSERT INTO tableA (Aid, ACode, ATimestamp)

    SELECT

    Aid

    ,ACode

    ,MIN(ATimestamp) ATimestamp

    FROM dbo.ALog al

    WHERE AId > 0

    AND ACode IN ('RunQuote', 'Generatedocument')

    GROUP BY ACode, Aid

    ORDER BY ACode, Aid

    -...

  • RE: How was the record deleted!!

    SJanki (8/14/2012)


    Hi All

    I am having a strange issue.

    From .NET application 5 records are inserted in a Table A.

    These records are inserted at datetime=2012-08-14 14:14:49.000

    There is another functionality where another...

  • RE: save varible in procedure

    EXEC(@aa)

    There are a number of errors in this stored procedure - would you be interested in knowing what they are?

  • RE: Querying Data From One Table Against Another Table For All Results

    Lynn Pettis (8/14/2012)


    ChrisM@Work (8/14/2012)


    Here's an alternative using PARSENAME()

    SELECT

    bi.Building_Name,

    COUNT(di.DeviceNum) NumberOfDevices

    FROM #Building_Information bi

    INNER JOIN #Device_Information di

    ON PARSENAME(bi.Subnet,4) = PARSENAME(di.IP_Address,4)

    AND PARSENAME(bi.Subnet,3) = PARSENAME(di.IP_Address,3)

    AND PARSENAME(bi.Subnet,2) =...

  • RE: How do you use a sub query in a join?

    dwilliscp (8/14/2012)


    dwilliscp (8/14/2012)


    Thanks for your help... I just could not figure out how to word the statement ... looking at some samples I found on the internet.

    Thanks for the...

  • RE: How do you use a sub query in a join?

    SELECT

    d.Delivery,

    d.Delivery_Item,

    n.Sales_Order_Number,

    d.REF_DOC,

    n.Notification_cnt

    FROM ztb_Carrier_Delivery_Metrics d

    INNER JOIN (

    SELECT

    sales_order_number,

    Notification_cnt = COUNT(sales_order_number)

    FROM ztb_IMP_Notifications

    GROUP BY sales_order_number

    ) n

    ON n.Sales_Order_Number = d.REF_DOC

    WHERE d.Ref_Doc > ''

  • RE: Querying Data From One Table Against Another Table For All Results

    Here's an alternative using PARSENAME()

    SELECT

    bi.Building_Name,

    COUNT(di.DeviceNum) NumberOfDevices

    FROM #Building_Information bi

    INNER JOIN #Device_Information di

    ON PARSENAME(bi.Subnet,4) = PARSENAME(di.IP_Address,4)

    AND PARSENAME(bi.Subnet,3) = PARSENAME(di.IP_Address,3)

    AND PARSENAME(bi.Subnet,2) = PARSENAME(di.IP_Address,2)

    GROUP BY Building_Name;

  • RE: Calculating average for 3 consecutive years

    WannaBee (8/14/2012)


    Thank you so much Chris 🙂

    That works just perfect!

    You're welcome - thanks for the nice feedback 🙂

  • RE: The multi-part identifier could not be bound.

    kgillispie (8/14/2012)


    Thanks for the help!

    You're welcome, though I get the feeling that we could have given a lot more. Can you post your modified code? It's likely that folks can...

  • RE: Avoiding Stored Procedures

    call.copse (8/14/2012)


    Jeff Moden (8/14/2012)


    call.copse (8/14/2012)


    Point 3 Managing and using auto generated CRUD procs is definitely slower than using an ORM. I promise!

    That's what I like ORMs for is basic CRUD....

Viewing 15 posts - 5,896 through 5,910 (of 10,144 total)