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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 QUERY SQL ON TWO TABLE
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pierre65
Starting Member

1 Posts

Posted - 04/26/2015 :  09:16:59  Show Profile  Reply with Quote
I have two table
Table A
NUMORD
POSORD
ARTICOLO
AMOUNT
Table B
NUMORD
POSORD
ARTICOLO
DATACONSEGNA

HOW CAN I OBTAIN
ALL RECORDS OF TABLE A (THE TOTAL AMOUNT OF TABLE A IS ALWAYS ALL RECORDS OF TABLE A) AND ONLY IF THERE IS A RECORD WITH NUMORD POSORD ARTICOLO A FIELD IN THE QUERY WHERE THERE IS ALL FIELD OF TABLE A AND A FIELD (TABLE B) DATACONSEGNA AND THERE ISN'T BLANK ?

Kristen
Test

United Kingdom
22859 Posts

Posted - 04/26/2015 :  12:38:02  Show Profile  Reply with Quote
This perhaps?

SELECT A.NUMORD, A.POSORD, A.ARTICOLO, A.AMOUNT, B.DATACONSEGNA
FROM Table_A AS A
      LEFT OUTER JOIN Table_B AS B
           ON B.NUMORD = A.NUMORD
          AND B.POSORD = A.POSORD
          AND B.ARTICOLO = A.ARTICOLO
          AND B.DATACONSEGNA <> ''
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000