Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Trying to list minimum and maximum years


Message #1 by David Taylor <dtaylor@d...> on Tue, 9 Jan 2001 09:32:04 -0000
--0-88623805-979040995=:47760
Content-Type: text/plain; charset=us-ascii


david

Nested SQL queries are for comparison purposes. Such as WHERE or HAVING. What you are doing here is trying to CREATE a VIEW then
querying it.

Of course you could do just that a proc that creates a view that from log then use that named view 

FROM (named View)

But I would have thought that you could simply query log for Max and Min. This surely should return simply one record.


  

  David Taylor <dtaylor@d...> wrote: 
The following sql should return one record with two fields, the first and
last years in the data, but it bombs out with an error. I can do this using
a view and a stored procedure, but I need it as one procedure. 

I don't really know if you can nest select's like this. 

SELECT distinct MIN(DATEPART(Yy, yearBit)) AS firstDemo, 
MAX(DATEPART(Yy, yearBit)) AS lastDemo
FROM (SELECT DATEPART(Yy, demoDate) AS yearBit
FROM log
GROUP BY DATEPART(Yy, demoDate))

Any suggestions?

.


To unsubscribe send a blank email to leave-sql_language-$subst('Recip.MemberIDChar')@p2p.wrox.com



---------------------------------
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!

---
You are currently subscribed to sql_language as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-sql_language-$subst('Recip.MemberIDChar')@p2p.wrox.com



  Return to Index