Forum Moderators: open
and in_date > isNull((
select max(out_date)
from aax_vehicle (nolock) where vin = 'XXXXXXXXX' and status_id in (17,62)
and company_id in (select distinct gcr.company_id
from aax_group_company_rel gcr (nolock)
inner join aax_company c (nolock) on gcr.company_id = c.company_id and c.type_id = 15
where group_id = (select gcr.group_id
from aax_group_company_rel gcr (nolock)
inner join aax_group g (nolock) on gcr.group_id = g.group_id and g.type_id = 16
where gcr.company_id = 457)))
, in_date-1)
AND in_date > isNull(
(
SELECT max(out_date)
FROM aax_vehicle (nolock)
WHERE vin = 'XXXXXXXXX' AND status_id in (17,62)
AND company_id IN (
SELECT distinct gcr.company_id
FROM aax_group_company_rel gcr (nolock)
INNER JOIN aax_company c (nolock) ON gcr.company_id = c.company_id and c.type_id = 15
WHERE group_id = (
SELECT gcr.group_id
FROM aax_group_company_rel gcr (nolock)
INNER JOIN aax_group g (nolock) ON gcr.group_id = g.group_id and g.type_id = 16
WHERE gcr.company_id = 457
)
)
),
in_date-1
)
Can someone please explain why the isNull(BLAH BLAH BLAH BLAH, in_date-1) would be used in the example below?
isNull([something], [something else])
is the same as:
IF([something] IS NULL, [something else], [something])
In other words, if [something] appears to be NULL, use the value of the [something else] and otherwise just use [something]
I don't know though, why it's written down like it is, because it doesn't make much sense.
If the product of all those subqueries is NULL, what's left is:
in_date > in_date-1
Maybe it has some logic in the bigger picture, but there's really no telling with the information you just gave. It might as well be a typo too