@Query(value = "select i.[Number] + '' + ic.Code + ''+ a.Code + '' + l.MarketingLobCode…
- User
@Query(value = "select i.[Number] + '' + ic.Code + ''+ a.Code + '' + l.MarketingLobCode + '' + p.[Number] " + "+ '' + insp.Code + '' + isnull(party.Tin,'0') + ''" + " + isnull(JSON_VALUE(po.ObjectData, '$.PlateNumber'),'NA/PN') + '' +isnull(party.crs,'null/crs')" + "from meru.Invoice i " + "join meru.Policy p on i.PolicyId = p.Id " + "join meru.InsuranceCompany ic on ic.Id = p.InsuranceCompanyId " + "join meru.Agent a on a.Id = p.AgentId " + "join meru.InsLob il on il.InsPackageId = p.PackageId " + "join meru.LobRegistry l on l.Id = il.LobRegistryId " + "join meru.Policyholder h on h.id= p.PolicyholderId " + "join meru.Party party on party.Id = h.PersonId " + "join meru.InsPackage insp on p.PackageId = insp.Id " + "join meru.PolicyObject po on p.Id = po.PolicyId " + "join meru.PolicyInsuredPerson pip on party.Id = pip.PersonId " + "where p.Deleted=0 and i.Deleted=0 and ic.code='010' " + "group by i.[Number], ic.Code, a.Code, l.MarketingLobCode, p.[Number], insp.Code, party.Tin, po.ObjectData, party.crs ", nativeQuery = true) List findUniqueAutoErgoInvoicesWithAllData();
with this query hoqw can i acquire from party tble the crs for the policy holder and separately from policyinsured person( agains crs from party)?
- Assistant
To acquire the "crs" for the policy holder from the party table and separately from the policy insured person, you can modify your query as follows:
@Query(value = "select i.[Number] + '' + ic.Code + '' + a.Code + '' + l.MarketingLobCode + '' + p.[Number] " + "+ '' + insp.Code + '' + isnull(party.Tin,'0') + ''" + " + isnull(JSON_VALUE(po.ObjectData, '$.PlateNumber'),'NA/PN')" + " + isnull(party.crs,'null/crs') as uniqueData," + " isnull(party.crs,'null/crs') as partyCrs," + " isnull(pip.crs,'null/crs') as insuredPersonCrs" + " from meru.Invoice i" + " join meru.Policy p on i.PolicyId = p.Id" + " join meru.InsuranceCompany ic on ic.Id = p.InsuranceCompanyId" + " join meru.Agent a on a.Id = p.AgentId" + " join meru.InsLob il on il.InsPackageId = p.PackageId" + " join meru.LobRegistry l on l.Id = il.LobRegistryId" + " join meru.Policyholder h on h.id= p.PolicyholderId" + " join meru.Party party on party.Id = h.PersonId" + " join meru.InsPackage insp on p.PackageId = insp.Id" + " join meru.PolicyObject po on p.Id = po.PolicyId" + " join meru.PolicyInsuredPerson pip on party.Id = pip.PersonId" + " where p.Deleted=0 and i.Deleted=0 and ic.code='010'" + " group by i.[Number], ic.Code, a.Code, l.MarketingLobCode, p.[Number], insp.Code, party.Tin, po.ObjectData, party.crs, pip.crs", nativeQuery = true) List<Object[]> findUniqueAutoErgoInvoicesWithAllData(); - User
- isnull(pip.crs,'null/crs') as insuredPersonCrs: This retrieves the “crs” value from the policy insured person table. i dont have crs column in pip only in party and i want for policyholder and PolicyInsuredPerson too .Take separate from party table
- Assistant
If the "crs" column is only present in the party table and not in the PolicyInsuredPerson table (pip), you can modify the query to retrieve the "crs" value only from the party table for both the policy holder and the policy insured person. Here is the modified query:
@Query(value = "select i.[Number] + '' + ic.Code + '' + a.Code + '' + l.MarketingLobCode + '' + p.[Number] " + "+ '' + insp.Code + '' + isnull(party.Tin,'0') + ''" + " + isnull(JSON_VALUE(po.ObjectData, '$.PlateNumber'),'NA/PN')" + " + isnull(party.crs,'null/crs') as uniqueData," + " isnull(party.crs,'null/crs') as partyCrs," + " isnull(party.crs,'null/crs') as insuredPersonCrs" + " from meru.Invoice i" + " join meru.Policy p on i.PolicyId = p.Id" + " join meru.InsuranceCompany ic on ic.Id = p.InsuranceCompanyId" + " join meru.Agent a on a.Id = p.AgentId" + " join meru.InsLob il on il.InsPackageId = p.PackageId" + " join meru.LobRegistry l on l.Id = il.LobRegistryId" + " join meru.Policyholder h on h.id= p.PolicyholderId" + " join meru.Party party on party.Id = h.PersonId" + " join meru.InsPackage insp on p.PackageId = insp.Id" + " join meru.PolicyObject po on p.Id = po.PolicyId" + " join meru.PolicyInsuredPerson pip on party.Id = pip.PersonId" + " where p.Deleted=0 and i.Deleted=0 and ic.code='010'" + " group by i.[Number], ic.Code, a.Code, l.MarketingLobCode, p.[Number], insp.Code, party.Tin, po.ObjectData, party.crs", nativeQuery = true) List<Object[]> findUniqueAutoErgoInvoicesWithAllData();