Note that there are some explanatory texts on larger screens.

plurals
  1. POT-SQL ORDER BY according to a condition
    primarykey
    data
    text
    <p>I am writing some sort of resources management system.</p> <p>A resource is an instance of a definition. A definition is the metadata, basically it contains the properties.</p> <p>This is in general my DB:</p> <pre><code>TypeDefinition id name =============== 1 CPU PropertyDefinition id name typeDefinitionId valueType ================================================ 1 frequency 1 int 2 status 1 string TypeInstance id name typeDefinitionId ================================= 1 CPU#1 1 2 CPU#2 1 PropertyInstanceValue id propertyDefinitionId typeInstanceId valueType intValue StringValue FloatValue ======================================================================================== 1 1 1 int 10 2 2 1 string Pending 3 1 2 int 20 4 2 2 string Approved </code></pre> <p><em><strong>REQUIREMENT:</em></strong></p> <p>order all resources according to a <strong>specific property value</strong>.</p> <p>For example: order all resources according to their <strong>status</strong> --> Meaning CPU#2 will appear before CPU#1 because “Approved” is before “Pending”.</p> <p>If we were to order according to <strong>frequency</strong>, CPU#1 will appear before CPU#2 because 10 is before 20.</p> <p>So I need to sort each time according to a different column (intValue / stringValue/ FloatValue / etc), depending on the property's valueType.</p> <p>Any suggestion?</p> <p><em><strong>LIMITATION:</em></strong></p> <p>PIVOT is currently the only option we've thought of, but it's not really possible since the DB is huge and I need the query to be as fast as possible.</p> <p>Thanks a lot in advance,</p> <p>Michal.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload