Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract information on 4 table

Status
Not open for further replies.

garmoska89

Programmer
Oct 25, 2011
4
MD

--select produse.model, produse.producator , produse.tip, max(pret) as pret_minim from produse,
select produse.model,produse.producator,produse.tip,pret from produse,
(
select model,pret from imprimante where pret=(select MAX(pret) from imprimante)
union
select model,pret from laptop_uri where pret=(select MAX(pret) from laptop_uri)
union
select model,pret from pc_uri where pret=(select MAX(pret) from pc_uri))as s2 where produse.model=s2.model
my answer is:
1233 A PC 980
1276 A imprimante 400
1288 A imprimante 400
1750 B Laptop_uri 1200


NOOOOO!! i need answer: 1 result: 1750 B Laptop_uri 1200
how i do i do
 
try:

Code:
select [!]Top 1[/!] produse.model,produse.producator,produse.tip,pret from produse,
(
select model,pret from imprimante where pret=(select MAX(pret) from imprimante)
union
select model,pret from laptop_uri where pret=(select MAX(pret) from laptop_uri) 
union
select model,pret from pc_uri where pret=(select MAX(pret) from pc_uri))as s2 where produse.model=s2.model
[!]Order By s2.pret DESC[/!]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
no i need use function max()
if I use only max(pret) its ork
result:id=1 max_pret=1200
no i need use max function on 2 table on thhe moment s2 and produse
do you know?
 
George respons should do the work.
Did you try it?

It's ok? Este in regula ?Sabin


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top