Wrox Programmer Forums
|
SQL Server 2008 General discussion of SQL Server *2008* version only - not related to a specific book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2012, 10:59 AM
Authorized User
 
Join Date: Sep 2006
Posts: 73
Thanks: 6
Thanked 0 Times in 0 Posts
Default Help With Not Equal Query

Hi All,

I am trying to write a query to pull out the next order but it isn't working if the next order is equal to the order that I am omitting. It works when the next order is different but when pulling the next order that is equal to 'Glucose' with a entered_date of ''2012-12-11 06:33:27.108', it is not displaying.

Thanks for any help!

Code:
SELECT
    t.name, MAX(date)
FROM
    (SELECT TOP 1
        o.name, MAX(o.entered_date) as date
     FROM
        dbo.orders o
    WHERE 
        o.clientid= 296400200
        AND o.name <> 'GLUCOSE'
        AND o.entered_date <> '2012-12-11 06:35:55.120'
        
    GROUP BY o.name
    ORDER BY date desc) t
GROUP BY t.name





Similar Threads
Thread Thread Starter Forum Replies Last Post
INNER JOIN Not EQUAL rylemer Access VBA 3 May 8th, 2017 01:35 AM
What's behind the 'Equal' and 'LinkedList' buttons Everard Hughes BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 1 September 27th, 2008 08:44 AM
~* Total pages are not equal *~ chakravarthy_vr Reporting Services 2 October 13th, 2006 03:56 PM
Set form value equal to databse fs22 Javascript How-To 17 July 16th, 2004 04:39 AM
Multiple Not Equal rylemer Access 5 January 23rd, 2004 04:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.