You are here: Re: SQL query - duplicate records - different dates - how to get only latest information? « MsSQL Server « IT news, forums, messages
Re: SQL query - duplicate records - different dates - how to get only latest information?

Posted by clare at snyder.on.ca on 03/20/06 17:53

On 20 Mar 2006 06:18:15 -0800, "figital" <mharen@gmail.com> wrote:

>Clare,
>
>You usually can't just take pieces of a large query and expect them to
>work all by themselves.

I realize that, but SUBQUERIES can work on their own.
>
>What is this in the 3rd line, from your post at Sat, Mar 18 2006 2:20
>pm?:

Well, I'll have to guess as I have no record of a 2:20pm post on Sat.,
but the code will be either Erlund's or Hugos, and I think it has been
mis-copied. The closest I can see is :

GROUP BY custid)AS p1 ON p1.custid=c.custid from Hugo in the early
stages, or:
GROUP BY custid)
AS p1
ON p1.custid=c.custid
From Hugo's final version, which, by the way, appears to be the only
one that actually works the way I had intended it to. I wish I could
completely understand the query, and it might be helpfull if Hugo
could put a documented version of the code up for the edification of
all of us.

How 'bout it Hugo??
You have already gone above and beyond, but it is VERY obvious you
know what you are doing, and a quick explanation of what you actually
did - what each expression does, would definitely be appreciated by
myself, and I'm sure by "figital" and others.

Again, my thanks to all who have responded so far - and to Hugo and
Erlund in particular.

>
> SELECT polid. polexpdate =MAX (polexpdate)
> FROM afw_basicpolinfo p WHERE p.polno like '1932700%'
> GROUP BY polid AS p1 ON p1.polid-p1 p1 polid -- <-- what is this?!
> Join afw_basicpolinfo p on p.polid = p1.polid
> AND p.polexpdate=p1.polexpdate
> WHERE p.polexpdate between '2006-04-15 00:00:00.000 and 2006-04-31
> 00:00:00.000'
> and c.email IS NOT NULL
>
>I have never seen syntax like that before.

*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация