How do I map a nested array of objects?

I have a use case where I need to query a NoSql table (AWS DynamoDb)

what gives me a list,
Each result must still be queried in the same table.

My table has 2 important columns –

1. sub_service_id
2. parent_id

The query takes place on Parent ID Column of the table
Each record will only have 1 parent_id,

However, a parent_id can exist in multiple rows. Therefore, a parent can have multiple children.

My table looks like this –
Enter image description here

With the exception of the first call, all remaining calls on the Parent ID Field,

be done with that sub_service_id from every record.

As you can see in the picture,
1st record is the parent of the 2nd record.
2nd record is the parent of the 3rd record.

Theoretically, records 1, 2, and 3 can contain multiple child records.
The NoSql table (AWS DynamoDb) can be queried with the primary key (sub_service_id) or an index (parent_id).

I've tried the following code, but I'm not able to figure out the logic –

var tree = {};
var requestBody = "";
module.exports.listServiceRelation = async (constants, requestBody) => {

    let requestContext = requestBody.context;
    requestBody = requestBody.request;

    let connection = await dynamoDb.getDynamoConnection(constants);
    console.log('db connection created!');

    let apiResponse = await getSubServiceHierarchy(constants, connection, requestBody.service_id);

};

let getSubServiceHierarchy = async (constants, connection, parent_id) => {

    let subServices = await dynamoDb.getSubServiceByParentId(constants, connection, parent_id);

    if(subServices != undefined && subServices.Items != undefined && subServices.Items.length > 0){

        let subServicesArr = ();
        for(let i in subServices.Items){
            let temp = {};

            let currObj = subServices.Items(i);

            temp.sub_service_id = currObj.sub_service_id;
            temp.sub_service_name = currObj.sub_service_name;
            temp.parent_id = currObj.parent_id;

            subServicesArr.push(temp);
        }
        tree(parent_id) = subServicesArr;

        for(let i in subServices.Items){
            let currObj = subServices.Items(i);

            let grandChildren = await dynamoDb.getSubServiceByParentId(constants, connection, currObj.sub_service_id);

            if(grandChildren != undefined && grandChildren.Items != undefined && grandChildren.Items.length > 0){
                getSubServiceHierarchy(constants, connection, grandChildren);
            }
        }
    }
    else{
        return ();
    }
};

I need help with a pseudo-code logic for my application.
My issue has to be something like this –

(
    {
        "sub_service_id": "1",
        "parent_id": "main_service_id",
        "children": ({
            "sub_service_id": "2",
            "parent_id": "1",
            "children": ({
                "sub_service_id": "3",
                "parent_id": "2",
                "children": ()
            })
        })
    },
    {
        "sub_service_id": "4",
        "parent_id": "main_service_id",
        "children": ()
    }
)

Dungeons and Dragons – What was the first adventure using nested text?

James Introcaso recently wrote a blog post titled "We Can Do Better Than Boxed Text", in which he describes the pros and cons of Boxed Text.

This has raised the question of who started it and How long is Boxtext already with us?

I've reviewed the earliest published adventures, but have not found any nested text yet. These included:

  • (1975) The first published D & D scenario of all time: the Blackmoor supplement to the "Temple of the Frog"
  • (1976) The first independent D & D module of all time: Palace of the Vampire Queen
  • (1978) The first module printed with the first edition of the basic D & D set: In Search of the Unknown
  • (1978) The first stand-alone module published by TSR G1: Steading of the Hill Giant Chief.
  • (1979) The second module in the D & D Basic Theorem: The Fortress in the Borderlands

None of these has a nested text, suggesting that it only arrived after 1979.

What was the first published adventure in D & D history using nested text?

rest – quoteCartRepositoryV1 Search for nested field

I would apply searchCriteria on /V1/carts/search to get all the cars that contain certain sku, I did this query

https://shop.dicanio.it/rest/all/V1/carts/search?[filterGroups][0][filters][0][field]=items.sku&searchCriteria[filterGroups][0][filters][0][value]=xxxxxxxxx&searchCriteria[filterGroups][0][filters][0][conditionType]=eq

but system I get an error. Is there a way to perform this type of operation?

The ultimate goal is to remove a specific item number from all active shopping carts.

Thank you in advance!

Java internal class and static nested class

From the Java tutorial:

Nested classes fall into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Nested non-static classes are called internal classes.

Static nested classes are accessed with the name of the attached class:

OuterClass.StaticNestedClass 

For example, use the following syntax to create an object for the statically nested class:

OuterClass.StaticNestedClass nestedObject = new OuterClass.StaticNestedClass(); 

Objects that are instances of an internal class exist in an instance of the external class. Consider the following classes:

class OuterClass {
  ...
  class InnerClass {
    ...
   }
 } 

An InnerClass instance can only exist in an OuterClass instance and has direct access to the methods and fields of the attached instance.

To create an instance of an internal class, you must first create an instance of the external class. Then create the internal object within the external object with the following syntax:

OuterClass.InnerClass innerObject = outerObject.new InnerClass(); 

See: Java Tutorial – Nested classes

Finally, note that there is also an internal class without a closing instance:

 class A {
   int t() {
     return 1;
   }
   static A a = new A() {
      int t() {
        return 2;
      }
   };
  } 

Here the new A() { ... } It is an internal class that is defined in a static context and does not have a closing instance.

Source: https://stackoverflow.com/a/70358/6999690

python – Returns the first element nested within an array of a JSON file

I have a MongoDB-hosted JSON file and I want to get the first element of the array array

{
  "_id": "5de9483c65222ef002ad6135",
  "election": "local-min-2015",
  "type": "FeatureCollection",
  "features": (
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": (
          (
            (
              5039258.279933322,
              5142586.1579948
            ),
            (
              5039615.847231327,
              5142411.105566747
            )
          )
        )
      },
      "properties": {
        "1": {
          "Partido Popular": "50.64"
        },
        "2": {
          "Partido Socialista Obrero Espanol": "3.22"
        },
        "3": {
          "Unidos Podemos": "1.29"
        },
        "4": {
          "Ciudadanos": "26.18"
        },
        "5": {
          "Vox": "18.45"
        },
        "id": 96918,
        "parent_id": 96916,
        "common_id": "11.01",
        "common_name": "11.01",
        "has_children": true,
        "shape_type_id": 5,
        "shape_type_name": "Majoritarian District",
        "value": "No Data",
        "color": null,
        "title_location": "Majoritarian District: 11.01",
        "Total Voter Turnout (%)": 55.08
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": (
          (
            (
              5039258.279933322,
              5142586.1579948
            ),
            (
              5039615.847231327,
              5142411.105566747
            )
          )
        )
      },
      "properties": {
        "1": {
          "Partido Popular": "45.64"
        },
        "2": {
          "Partido Socialista Obrero Espanol": "7.22"
        },
        "3": {
          "Unidos Podemos": "2.29"
        },
        "4": {
          "Ciudadanos": "26.18"
        },
        "5": {
          "Vox": "18.45"
        },
        "id": 96919,
        "parent_id": 96916,
        "common_id": "11.01",
        "common_name": "11.01",
        "has_children": true,
        "shape_type_id": 5,
        "shape_type_name": "Majoritarian District",
        "value": "No Data",
        "color": null,
        "title_location": "Majoritarian District: 11.01",
        "Total Voter Turnout (%)": 55.08
      }
    }
  )
}

I tried the following:

import pymongo
from bson.son import SON
import json

import os

client = pymongo.MongoClient("mongodb://localhost:27017/")

db = client("Richmond")

collection = db('Collection')

# select the documents where the field features contains the field 0
cursor = collection.find(
    { "election": "local-maj-2017" },
    { "features.0": 1 }#, "type": 0, "election": 0, "_id": 0 } # get the very first item of the features array
)

for doc in cursor:
    print(doc)

But it brings me back:

(base) C:UsersantoiDocumentsProgrammingRichmondMongo>python query_mongdb.py
{'_id': ObjectId('5de9483c65222ef002ad6135'), 'features': ({}, {})}

SQL Server – Optimize the query with nested inner query and case statements

I wrote the following query from someone who is targeting Microsoft SQL Server 2017. I do not have access to the database to create indexes, and so on. Therefore, I can only optimize the following query as efficiently as possible.

My question here is

Can I use Case and WHEN in the inner query as used in the following query? I am also currently trying to remove nested queries using the inner join.

All other ideas are appreciated for the following questions. I'm not asking for a final optimized query, but for a specific suggestion for the following query.

SELECT CoverPremium.COVER_PREMIUM_SET_ID
    ,CoverPremium.POLICY_ID
    ,CoverPremium.ADDRESS_ID
    ,CoverPremium.STATUS_CODE
    ,CoverPremium.COVER_PREMIUM_MODEL_ID
    ,CoverPremium.SUB_PRODUCT_REF
    ,CoverPremium.COVER_PREMIUM_MODEL_REF
    ,CoverPremium.Description
    ,CoverPremium.PREMIUM_LEVEL_CODE
    ,CoverPremium.PREMIUM_PAYABLE
    ,CoverPremium.PREMIUM_DUE
    ,CoverPremium.COMMISSION_GST
    ,CoverPremium.COMMISSION
    ,CoverPremium.COMMISSION_TOTAL
    ,CoverPremium.TERRORISM_GST
    ,CoverPremium.TERRORISM_RI
    ,CoverPremium.STAMP_DUTY
    ,CoverPremium.GST
    ,CoverPremium.FSL
    ,CoverPremium.MODIFIED_PREMIUM
    ,CoverPremium.TECHNICAL_PREMIUM
    ,CoverPremium.BASE_PREMIUM
    ,CoverPremium.PREMIUM_PAYABLE_TERM
    ,CoverPremium.PREMIUM_DUE_TERM
    ,CoverPremium.COMMISSION_GST_TERM
    ,CoverPremium.COMMISSION_TERM
    ,CoverPremium.COMMISSION_TOTAL_TERM
    ,CoverPremium.TERRORISM_GST_TERM
    ,CoverPremium.TERRORISM_RI_TERM
    ,CoverPremium.STAMP_DUTY_TERM
    ,CoverPremium.GST_TERM
    ,CoverPremium.FSL_TERM
    ,CoverPremium.MODIFIED_PREMIUM_TERM
    ,CoverPremium.TECHNICAL_PREMIUM_TERM
    ,CoverPremium.BASE_PREMIUM_TERM
    ,CoverPremium.PREMIUM_PAYABLE_ANNUALISED
    ,CoverPremium.PREMIUM_DUE_ANNUALISED
    ,CoverPremium.COMMISSION_GST_ANNUALISED
    ,CoverPremium.COMMISSION_ANNUALISED
    ,CoverPremium.COMMISSION_TOTAL_ANNUALISED
    ,CoverPremium.TERRORISM_GST_ANNUALISED
    ,CoverPremium.TERRORISM_RI_ANNUALISED
    ,CoverPremium.STAMP_DUTY_ANNUALISED
    ,CoverPremium.GST_ANNUALISED
    ,CoverPremium.FSL_ANNUALISED
    ,CoverPremium.MODIFIED_PREMIUM_ANNUALISED
    ,CoverPremium.TECHNICAL_PREMIUM_ANNUALISED
    ,CoverPremium.BASE_PREMIUM_ANNUALISED
FROM (
    SELECT NULL AS COVER_PREMIUM_SET_ID
        ,a1.POLICY_ID
        ,a1.ADDRESS_ID
        ,a1.STATUS_CODE
        ,CPM_CHILD.PARENT_ID AS COVER_PREMIUM_MODEL_ID
        ,a1.SUB_PRODUCT_REF
        ,CPM.COVER_PREMIUM_MODEL_REF
        ,CPM.NAME AS Description
        ,CPM.PREMIUM_LEVEL_CODE AS PREMIUM_LEVEL_CODE
        ,sum(a1.PREMIUM_PAYABLE) PREMIUM_PAYABLE
        ,sum(a1.PREMIUM_DUE) PREMIUM_DUE
        ,sum(a1.COMMISSION_GST) COMMISSION_GST
        ,sum(a1.COMMISSION) COMMISSION
        ,sum(a1.COMMISSION_TOTAL) COMMISSION_TOTAL
        ,sum(a1.TERRORISM_GST) TERRORISM_GST
        ,sum(a1.TERRORISM_RI) TERRORISM_RI
        ,sum(a1.STAMP_DUTY) STAMP_DUTY
        ,sum(a1.GST) GST
        ,sum(a1.FSL) FSL
        ,sum(a1.MODIFIED_PREMIUM) MODIFIED_PREMIUM
        ,sum(a1.TECHNICAL_PREMIUM) TECHNICAL_PREMIUM
        ,sum(a1.BASE_PREMIUM) BASE_PREMIUM
        ,sum(a1.PREMIUM_PAYABLE_TERM) PREMIUM_PAYABLE_TERM
        ,sum(a1.PREMIUM_DUE_TERM) PREMIUM_DUE_TERM
        ,sum(a1.COMMISSION_GST_TERM) COMMISSION_GST_TERM
        ,sum(a1.COMMISSION_TERM) COMMISSION_TERM
        ,sum(a1.COMMISSION_TOTAL_TERM) COMMISSION_TOTAL_TERM
        ,sum(a1.TERRORISM_GST_TERM) TERRORISM_GST_TERM
        ,sum(a1.TERRORISM_RI_TERM) TERRORISM_RI_TERM
        ,sum(a1.STAMP_DUTY_TERM) STAMP_DUTY_TERM
        ,sum(a1.GST_TERM) GST_TERM
        ,sum(a1.FSL_TERM) FSL_TERM
        ,sum(a1.MODIFIED_PREMIUM_TERM) MODIFIED_PREMIUM_TERM
        ,sum(a1.TECHNICAL_PREMIUM_TERM) TECHNICAL_PREMIUM_TERM
        ,sum(a1.BASE_PREMIUM_TERM) BASE_PREMIUM_TERM
        ,sum(a1.PREMIUM_PAYABLE_ANNUALISED) PREMIUM_PAYABLE_ANNUALISED
        ,sum(a1.PREMIUM_DUE_ANNUALISED) PREMIUM_DUE_ANNUALISED
        ,sum(a1.COMMISSION_GST_ANNUALISED) COMMISSION_GST_ANNUALISED
        ,sum(a1.COMMISSION_ANNUALISED) COMMISSION_ANNUALISED
        ,sum(a1.COMMISSION_TOTAL_ANNUALISED) COMMISSION_TOTAL_ANNUALISED
        ,sum(a1.TERRORISM_GST_ANNUALISED) TERRORISM_GST_ANNUALISED
        ,sum(a1.TERRORISM_RI_ANNUALISED) TERRORISM_RI_ANNUALISED
        ,sum(a1.STAMP_DUTY_ANNUALISED) STAMP_DUTY_ANNUALISED
        ,sum(a1.GST_ANNUALISED) GST_ANNUALISED
        ,sum(a1.FSL_ANNUALISED) FSL_ANNUALISED
        ,sum(a1.MODIFIED_PREMIUM_ANNUALISED) MODIFIED_PREMIUM_ANNUALISED
        ,sum(a1.TECHNICAL_PREMIUM_ANNUALISED) TECHNICAL_PREMIUM_ANNUALISED
        ,sum(a1.BASE_PREMIUM_ANNUALISED) BASE_PREMIUM_ANNUALISED
    FROM uat_cod_helo.COVER_PREMIUM_MODEL CPM
        ,uat_cod_helo.COVER_PREMIUM_MODEL CPM_CHILD
        ,uat_cod_helo.SUB_PRODUCT SP
        ,PRODUCT P
        ,PRODUCT_SUB_PRODUCT PSP
        ,(
            SELECT COVER_PREMIUM_PART.COVER_PREMIUM_SET_ID
                ,COVER_PREMIUM_SET.POLICY_ID
                ,CASE 
                    WHEN COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE = 'PREMITEM'
                        THEN a.ADDRESS_ID
                    ELSE CASE 
                            WHEN COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE IN (
                                    'SITSUM'
                                    ,'SUBPRODSUM'
                                    )
                                THEN (
                                        SELECT ADDRESS.ADDRESS_ID
                                        FROM ADDRESS
                                        WHERE COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE IN (
                                                'SITSUM'
                                                ,'SUBPRODSUM'
                                                )
                                            AND ADDRESS.ADDRESS_REF = COVER_PREMIUM_SET.ENTITY_INSTANCE_REF
                                            AND ADDRESS.POLICY_ID = COVER_PREMIUM_SET.POLICY_ID
                                        )
                            END
                    END ADDRESS_ID
                ,a.STATUS_CODE
                ,(
                    SELECT CPM.COVER_PREMIUM_MODEL_ID
                    FROM COVER_PREMIUM_MODEL CPM
                    WHERE CPM.COVER_PREMIUM_MODEL_REF = COVER_PREMIUM_SET.COVER_PREMIUM_MODEL_REF
                    ) AS COVER_PREMIUM_MODEL_ID
                ,COVER_PREMIUM_SET.SUB_PRODUCT_REF
                ,COVER_PREMIUM_SET.COVER_PREMIUM_MODEL_REF
                ,COVER_PREMIUM_SET.DESCRIPTION
                ,COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_PAYABLE'
                            THEN TRANSACTION_AMOUNT
                        END) PREMIUM_PAYABLE
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_DUE'
                            THEN TRANSACTION_AMOUNT
                        END) PREMIUM_DUE
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_GST'
                            THEN TRANSACTION_AMOUNT
                        END) COMMISSION_GST
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION'
                            THEN TRANSACTION_AMOUNT
                        END) COMMISSION
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_TOTAL'
                            THEN TRANSACTION_AMOUNT
                        END) COMMISSION_TOTAL
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_GST'
                            THEN TRANSACTION_AMOUNT
                        END) TERRORISM_GST
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_RI'
                            THEN TRANSACTION_AMOUNT
                        END) TERRORISM_RI
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'STAMP_DUTY'
                            THEN TRANSACTION_AMOUNT
                        END) STAMP_DUTY
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'GST'
                            THEN TRANSACTION_AMOUNT
                        END) GST
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'FSL'
                            THEN TRANSACTION_AMOUNT
                        END) FSL
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'MODIFIED_PREMIUM'
                            THEN TRANSACTION_AMOUNT
                        END) MODIFIED_PREMIUM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TECHNICAL_PREMIUM'
                            THEN TRANSACTION_AMOUNT
                        END) TECHNICAL_PREMIUM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'BASE_PREMIUM'
                            THEN TRANSACTION_AMOUNT
                        END) BASE_PREMIUM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_PAYABLE'
                            THEN TERM_AMOUNT
                        END) PREMIUM_PAYABLE_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_DUE'
                            THEN TERM_AMOUNT
                        END) PREMIUM_DUE_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_GST'
                            THEN TERM_AMOUNT
                        END) COMMISSION_GST_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION'
                            THEN TERM_AMOUNT
                        END) COMMISSION_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_TOTAL'
                            THEN TERM_AMOUNT
                        END) COMMISSION_TOTAL_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_GST'
                            THEN TERM_AMOUNT
                        END) TERRORISM_GST_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_RI'
                            THEN TERM_AMOUNT
                        END) TERRORISM_RI_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'STAMP_DUTY'
                            THEN TERM_AMOUNT
                        END) STAMP_DUTY_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'GST'
                            THEN TERM_AMOUNT
                        END) GST_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'FSL'
                            THEN TERM_AMOUNT
                        END) FSL_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'MODIFIED_PREMIUM'
                            THEN TERM_AMOUNT
                        END) MODIFIED_PREMIUM_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TECHNICAL_PREMIUM'
                            THEN TERM_AMOUNT
                        END) TECHNICAL_PREMIUM_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'BASE_PREMIUM'
                            THEN TERM_AMOUNT
                        END) BASE_PREMIUM_TERM
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_PAYABLE'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) PREMIUM_PAYABLE_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_DUE'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) PREMIUM_DUE_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_GST'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) COMMISSION_GST_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) COMMISSION_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_TOTAL'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) COMMISSION_TOTAL_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_GST'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) TERRORISM_GST_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_RI'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) TERRORISM_RI_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'STAMP_DUTY'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) STAMP_DUTY_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'GST'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) GST_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'FSL'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) FSL_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'MODIFIED_PREMIUM'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) MODIFIED_PREMIUM_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'TECHNICAL_PREMIUM'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) TECHNICAL_PREMIUM_ANNUALISED
                ,MAX(CASE 
                        WHEN PREMIUM_MODEL_PART_REF = 'BASE_PREMIUM'
                            THEN FUTURE_ANNUALISED_AMOUNT
                        END) BASE_PREMIUM_ANNUALISED
            FROM COVER_PREMIUM_SET
            LEFT JOIN (
                SELECT SITUATION_SECTION.SITUATION_SECTION_ID
                    ,SITUATION_SECTION.POLICY_ID
                    ,SITUATION_SECTION.ADDRESS_ID
                    ,SITUATION_SECTION.SITUATION_SECTION_REF
                    ,SITUATION_SECTION.STATUS_CODE
                FROM SITUATION_SECTION
                    ,SECTION
                WHERE SITUATION_SECTION.POLICY_ID = SECTION.POLICY_ID
                    AND SITUATION_SECTION.SECTION_ID = SECTION.SECTION_ID
                ) a ON COVER_PREMIUM_SET.SITUATION_SECTION_REF = a.SITUATION_SECTION_REF
                AND COVER_PREMIUM_SET.POLICY_ID = a.POLICY_ID
            LEFT JOIN COVER_PREMIUM_PART ON COVER_PREMIUM_SET.COVER_PREMIUM_SET_ID = COVER_PREMIUM_PART.COVER_PREMIUM_SET_ID
            GROUP BY COVER_PREMIUM_PART.COVER_PREMIUM_SET_ID
                ,COVER_PREMIUM_SET.POLICY_ID
                ,COVER_PREMIUM_SET.DESCRIPTION
                ,COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE
                ,COVER_PREMIUM_SET.COVER_PREMIUM_MODEL_REF
                ,COVER_PREMIUM_SET.SUB_PRODUCT_REF
                ,a.SITUATION_SECTION_ID
                ,a.ADDRESS_ID
                ,a.STATUS_CODE
                ,COVER_PREMIUM_SET.ENTITY_INSTANCE_REF
            ) a1
    WHERE CPM.SUB_PRODUCT_ID = SP.SUB_PRODUCT_ID
        AND SP.SUB_PRODUCT_ID = PSP.SUB_PRODUCT_ID
        AND P.PRODUCT_ID = PSP.PRODUCT_ID
        AND P.PRODUCT_REF = 'SCTP_BUSINESS_PACK'
        AND CPM.PREMIUM_LEVEL_CODE = 'PREMRLUP'
        AND CPM_CHILD.PARENT_ID = CPM.COVER_PREMIUM_MODEL_ID
        AND CPM_CHILD.COVER_PREMIUM_MODEL_REF = a1.COVER_PREMIUM_MODEL_REF
    GROUP BY a1.POLICY_ID
        ,a1.ADDRESS_ID
        ,CPM_CHILD.PARENT_ID
        ,CPM.NAME
        ,CPM.PREMIUM_LEVEL_CODE
        ,a1.SUB_PRODUCT_REF
        ,CPM.COVER_PREMIUM_MODEL_REF
        ,a1.STATUS_CODE

    UNION

    SELECT COVER_PREMIUM_PART.COVER_PREMIUM_SET_ID
        ,COVER_PREMIUM_SET.POLICY_ID
        ,CASE 
            WHEN COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE = 'PREMITEM'
                THEN a.ADDRESS_ID
            ELSE CASE 
                    WHEN COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE IN (
                            'SITSUM'
                            ,'SUBPRODSUM'
                            )
                        THEN (
                                SELECT ADDRESS.ADDRESS_ID
                                FROM ADDRESS
                                WHERE COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE IN (
                                        'SITSUM'
                                        ,'SUBPRODSUM'
                                        )
                                    AND ADDRESS.ADDRESS_REF = COVER_PREMIUM_SET.ENTITY_INSTANCE_REF
                                    AND ADDRESS.POLICY_ID = COVER_PREMIUM_SET.POLICY_ID
                                )
                    END
            END ADDRESS_ID
        ,a.STATUS_CODE
        ,(
            SELECT CPM.COVER_PREMIUM_MODEL_ID
            FROM COVER_PREMIUM_MODEL CPM
            WHERE CPM.COVER_PREMIUM_MODEL_REF = COVER_PREMIUM_SET.COVER_PREMIUM_MODEL_REF
            ) AS COVER_PREMIUM_MODEL_ID
        ,COVER_PREMIUM_SET.SUB_PRODUCT_REF
        ,COVER_PREMIUM_SET.COVER_PREMIUM_MODEL_REF
        ,COVER_PREMIUM_SET.DESCRIPTION
        ,COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_PAYABLE'
                    THEN TRANSACTION_AMOUNT
                END) PREMIUM_PAYABLE
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_DUE'
                    THEN TRANSACTION_AMOUNT
                END) PREMIUM_DUE
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_GST'
                    THEN TRANSACTION_AMOUNT
                END) COMMISSION_GST
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION'
                    THEN TRANSACTION_AMOUNT
                END) COMMISSION
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_TOTAL'
                    THEN TRANSACTION_AMOUNT
                END) COMMISSION_TOTAL
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_GST'
                    THEN TRANSACTION_AMOUNT
                END) TERRORISM_GST
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_RI'
                    THEN TRANSACTION_AMOUNT
                END) TERRORISM_RI
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'STAMP_DUTY'
                    THEN TRANSACTION_AMOUNT
                END) STAMP_DUTY
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'GST'
                    THEN TRANSACTION_AMOUNT
                END) GST
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'FSL'
                    THEN TRANSACTION_AMOUNT
                END) FSL
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'MODIFIED_PREMIUM'
                    THEN TRANSACTION_AMOUNT
                END) MODIFIED_PREMIUM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TECHNICAL_PREMIUM'
                    THEN TRANSACTION_AMOUNT
                END) TECHNICAL_PREMIUM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'BASE_PREMIUM'
                    THEN TRANSACTION_AMOUNT
                END) BASE_PREMIUM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_PAYABLE'
                    THEN TERM_AMOUNT
                END) PREMIUM_PAYABLE_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_DUE'
                    THEN TERM_AMOUNT
                END) PREMIUM_DUE_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_GST'
                    THEN TERM_AMOUNT
                END) COMMISSION_GST_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION'
                    THEN TERM_AMOUNT
                END) COMMISSION_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_TOTAL'
                    THEN TERM_AMOUNT
                END) COMMISSION_TOTAL_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_GST'
                    THEN TERM_AMOUNT
                END) TERRORISM_GST_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_RI'
                    THEN TERM_AMOUNT
                END) TERRORISM_RI_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'STAMP_DUTY'
                    THEN TERM_AMOUNT
                END) STAMP_DUTY_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'GST'
                    THEN TERM_AMOUNT
                END) GST_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'FSL'
                    THEN TERM_AMOUNT
                END) FSL_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'MODIFIED_PREMIUM'
                    THEN TERM_AMOUNT
                END) MODIFIED_PREMIUM_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TECHNICAL_PREMIUM'
                    THEN TERM_AMOUNT
                END) TECHNICAL_PREMIUM_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'BASE_PREMIUM'
                    THEN TERM_AMOUNT
                END) BASE_PREMIUM_TERM
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_PAYABLE'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) PREMIUM_PAYABLE_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'PREMIUM_DUE'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) PREMIUM_DUE_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_GST'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) COMMISSION_GST_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) COMMISSION_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'COMMISSION_TOTAL'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) COMMISSION_TOTAL_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_GST'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) TERRORISM_GST_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TERRORISM_RI'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) TERRORISM_RI_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'STAMP_DUTY'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) STAMP_DUTY_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'GST'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) GST_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'FSL'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) FSL_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'MODIFIED_PREMIUM'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) MODIFIED_PREMIUM_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'TECHNICAL_PREMIUM'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) TECHNICAL_PREMIUM_ANNUALISED
        ,MAX(CASE 
                WHEN PREMIUM_MODEL_PART_REF = 'BASE_PREMIUM'
                    THEN FUTURE_ANNUALISED_AMOUNT
                END) BASE_PREMIUM_ANNUALISED
    FROM COVER_PREMIUM_SET
    LEFT JOIN (
        SELECT SITUATION_SECTION.SITUATION_SECTION_ID
            ,SITUATION_SECTION.POLICY_ID
            ,SITUATION_SECTION.ADDRESS_ID
            ,SITUATION_SECTION.SITUATION_SECTION_REF
            ,SITUATION_SECTION.STATUS_CODE
        FROM SITUATION_SECTION
            ,SECTION
        WHERE SITUATION_SECTION.POLICY_ID = SECTION.POLICY_ID
            AND SITUATION_SECTION.SECTION_ID = SECTION.SECTION_ID
        ) a ON COVER_PREMIUM_SET.SITUATION_SECTION_REF = a.SITUATION_SECTION_REF
        AND COVER_PREMIUM_SET.POLICY_ID = a.POLICY_ID
    LEFT JOIN COVER_PREMIUM_PART ON COVER_PREMIUM_SET.COVER_PREMIUM_SET_ID = COVER_PREMIUM_PART.COVER_PREMIUM_SET_ID
    GROUP BY COVER_PREMIUM_PART.COVER_PREMIUM_SET_ID
        ,COVER_PREMIUM_SET.POLICY_ID
        ,COVER_PREMIUM_SET.DESCRIPTION
        ,COVER_PREMIUM_SET.PREMIUM_LEVEL_CODE
        ,COVER_PREMIUM_SET.COVER_PREMIUM_MODEL_REF
        ,COVER_PREMIUM_SET.SUB_PRODUCT_REF
        ,a.SITUATION_SECTION_ID
        ,a.ADDRESS_ID
        ,a.STATUS_CODE
        ,COVER_PREMIUM_SET.ENTITY_INSTANCE_REF
    ) CoverPremium
WHERE CoverPremium.POLICY_ID = 77780029
ORDER BY CoverPremium.ADDRESS_ID
    ,CoverPremium.COVER_PREMIUM_SET_ID

Optimization – What happens to register usage in deeply nested function calls (theoretically)?

Thank you for sending a reply to Computer Science Stack Exchange!

  • Please be sure too answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarify or respond to other answers.
  • Make statements based on opinions; Cover them with references or personal experience.

Use MathJax to format equations. Mathjax reference.

For more information, see our tips for writing great answers.

ember.js – Emberjs – How do I render nested route templates without parent route content?

I still want to use existing nested routes without displaying top-level content when accessing nested routes. I'm not sure if that's possible?

Originally, my requirement was to keep a list of z. For example, to display food and give the user the opportunity to add a food foods/add , Use of outlet The tag at the top of the list template allowed a form to add a food item that appeared at the top of the list and returned to "" food After adding, the list was displayed without the form.

The request has now changed and it is necessary to display the form without the contents of the list and, after a successful addition, to display the list without any form.

I know that I could abandon the subroute approach and create a route like food-add but is there any other way to get the subroute (and the file structure I like) but allow the template for it foods/add without rendering the list content?

procedural programming – make nested if and for loops distinguishable

Thank you for your reply to Mathematica Stack Exchange!

  • Please be sure too answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarify or respond to other answers.
  • Make statements based on opinions; Cover them with references or personal experience.

Use MathJax to format equations. Mathjax reference.

For more information, see our tips for writing great answers.

transformation – Nested transform.position in Unity

The following code works so well, but it is so long.

How can I? A for Loop to write a short script for any number of prefabs?

public GameObject prefab1;
public GameObject prefab2;
public GameObject prefab3;
float timCounter = 0f;

void FixedUpdate()
{
  timCounter += Time.deltaTime;

  float()  r = {3,2,1};
  float()  f = {3,2,1};

  //motion on a circle

  float x = r(0) * Mathf.Cos(f(0) * timCounter);
  float y = r(0) * Mathf.Sin(f(0) * timCounter);

  float x1 = r(1) * Mathf.Cos(f(1) * timCounter);
  float y1 = r(1) * Mathf.Sin(f(1) * timCounter);

  float x2 = r(2) * Mathf.Cos(f(2) * timCounter);
  float y2 = r(2) * Mathf.Sin(f(2) * timCounter);

  float z = 0;

  //position of a any prefab_n = position of prefab_(n-1) + Vector3(x,y,z)

  prefab1.transform.position = new Vector3(x,y,z);

  prefab2.transform.position = prefab1.transform.position + new 
  Vector3(x1,y1,z);

  prefab3.transform.position = prefab2.transform.position + new 
  Vector3(x2,y2,z);
 }