how to use select field value in where clause (merged) [message #684019] |
Wed, 24 March 2021 10:35  |
 |
Sekhar6617
Messages: 22 Registered: March 2021
|
Junior Member |
|
|
Hi Team,
How to use the select field from another table into main sql where clause. Do we need to repeat the same sub-query wrote in select in where clause as well or do we have any logic to get the select value in where clause. See below sql, in that how to get the startdate in case statement of where clause.
SELECT a.invoiceid,
a.invoicenum,
a.invoicedate,
(
SELECT Max(b.start_date)
FROM invoice_ln_tbl b
WHERE a.invoiceid = b.invoiceid) AS startdate,
c.taxrate
FROM invoice_tbl a,
invoicetax c
WHERE a.invoiceid = c.invoiceid
AND
CASE
WHEN a.invoicedate IS NULL THEN a.invoicedate <= startdate
WHEN a.invoicedate IS NOT NULL THEN a.invoicedate <= sysdate
END
|
|
|
|
|