Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL 2008 AP

Author  Topic 

rdoyal
Starting Member

15 Posts

Posted - 2010-10-22 : 17:44:46
SELECT VendorName, MAX(InvoiceNumber) AS InvoiceNumber, MAX(InvoiceTotal) AS Invoicetotal, MIN(InvoiceDate) AS EarliestDate
FROM Vendors JOIN Invoices
ON Vendors.VendorID = Invoices.VendorID
GROUP BY VendorName
ORDER BY EarliestDate DESC

Returns 34 rows, which is right! But I'm not understanding how to do a subquery in the Statement? Pseudocode, I'm Totaly Lost. I would be thankful for any help!

--------------------------------------------------------------------------------

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-10-22 : 18:07:32
What do you need to do a subquery for? You haven't provided a case for it.
Go to Top of Page

rdoyal
Starting Member

15 Posts

Posted - 2010-10-22 : 19:05:09
Can you elaborate on that a little more Please? We have been working on subquerys thoughtout this Chapter and I just asummed that this one would have one also. I do know from others that is has an AND in it. and they have mentioned a page reference of 203, which is Pseudocode.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-10-22 : 23:29:13
I have no idea what you're talking about.
Go to Top of Page

rdoyal
Starting Member

15 Posts

Posted - 2010-10-23 : 00:41:48
I am trying to do a subquery for this statement that will return 34 rows with the earlier invoice date. I am Useing 2008 AP. My Group is underlined

SELECT VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal
FROM Vendors JOIN
(SELECT MIN(InvoiceDate) AS EarliestDate
FROM Invoices JOIN
GROUP BY VendorName, InvoiceNumber, EarliestDate , InvoiceTotal
ORDER BY EarliestDate DESC)

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-10-23 : 01:06:54
quote:
Originally posted by robvolk

I have no idea what you're talking about.



He is expecting that everyone here should by default know about his practice questions.

PBUH

Go to Top of Page
   

- Advertisement -