Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have two table Table ANUMORDPOSORDARTICOLOAMOUNTTable BNUMORDPOSORDARTICOLODATACONSEGNAHOW 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
22859 Posts
Posted - 2015-04-26 : 12:38:02
This perhaps?
SELECT A.NUMORD, A.POSORD, A.ARTICOLO, A.AMOUNT, B.DATACONSEGNAFROM 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 <> ''