Groups | Blog | Home
all groups > sql server programming > november 2004 >

sql server programming : sql join question



CFI
11/22/2004 10:11:36 PM
Hi,
Your help would be highly appreciated! I have a next kind
of problem.

I have two tables

A
B

A table includes some information about production.
Example product A has been made in two days, so
information i need is on a two lines and both lines has
different date information(20.11.2004 and 21.11.2004).

On a table B I have information i need, to be sure that
the production is ready and the product has been made. Now
I join A and B tables together(product number join), but
in sql i get in return two lines(I need the date info in
query) for the same product, but I only need the smallest
one (20.11.2004).

So i need sum figure, but so, that query shows only the
smaller date.

Thanks for any help,
oj
11/22/2004 10:21:09 PM
Without seeing the ddls, here is a guess.

select product_name, min(datecolumn) as [date], sum(quantity) as [totals]
from A join B on A.productid=B.productid
group by product_name


[quoted text, click to view]

Aaron [SQL Server MVP]
11/23/2004 1:16:42 AM
Instead of a word problem, can you please provide table structure, sample
data, and desired results.
See http://www.aspfaq.com/5006 for help on providing this information.

--
http://www.aspfaq.com/
(Reverse address to reply.)




[quoted text, click to view]

AddThis Social Bookmark Button