Skip to content
Advertisement

Query dates from different rows in the same table to appear on the same row in the query

I have seen many posts about this issue using joins but not for the same table. I am trying to compare the dates from different rows on the same table. I am writing tax software that tracks liens. The tax charge is on one line and any interest charged is on another. I need to compare the dates of the tax line and the dates of the interest line here is the query I tried

The sub query is returning multiple records. I want the TaxLineLienDate and InterestLineLienDate on the same line of the query for each ID. Any help would be appreciated. I am using SQL Server.

Advertisement

Answer

If I’m understanding correctly, you can use conditional aggregation for this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement