August 30, 2017 at 7:20 am
desc cust_master
locn_no varchar(20)
cust_no varchar(20)
address varchar(20)
desc billed_det
cust_no varchar(20)
order_amount numeric(5,2)
oreder_date datetime
expecting output:
cust_no locn_no
details who are not billed after 31_mar-2017 to till date
August 30, 2017 at 7:32 am
FFS, how about some real tables? Since you didn't provide consumable data, here's my best guess.
SELECT CM.cust_no
, loc_No
FROM Cust_Master CM
WHERE NOT EXISTS
(SELECT 1
FROM desc billed_det det
WHERE det.cust_no = CM.cust_no
AND order_date > '31-Mar-2017);
August 30, 2017 at 7:50 am
raghuldrag - Wednesday, August 30, 2017 7:20 AMdesc cust_masterlocn_no varchar(20)
cust_no varchar(20)
address varchar(20)desc billed_det
cust_no varchar(20)
order_amount numeric(5,2)
oreder_date datetimeexpecting output:
cust_no locn_no
details who are not billed after 31_mar-2017 to till date
Use WHERE NOT EXISTS ()
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply