Azure SQL Server
Hi Team, I am having a base table in sql server (say node), which has a foreign key for attribute. In another table which stores values as per attributes (using attribute foreign key), i have a reference of the base table. For a single row of base table, if it references 4 attributes, than in other table which stores attribute values, there will be 4 rows, one for each of the attribute of the base table. I want to apply multiple attribute sorting here, such that for attribute A all values to be sorted ascending and for attribute B all values to be sorted descending. This means for all rows in attribute value table where value of a particular attribute of type A are same, for same node, all attributes of type B should get sorted descending. I tried applying this using cases in order by, it is not working. It sorts rows of attribute value of both the attribute type independently. First, it sorts all type A attributes in ascending order then it sorts all type values in descending order with no relation to attribute value rows of type A. Also, node rows are repeated here, i want to get the sequence of node rows such that its corresponding rows in attribute Value table for attribute A are sorted ascending, for same node rows (no repetition of nodes), attributes of type B to be sorted descending. There could be any number of attributes with combination of asc and desc to sort. Please help me achieve this, any working example will be of great help. Thanks, Salil
Please post table design as DDL, some sample data as DML and the expected result.
Hi @salilsingh-9961 ,
Could you share us the information that Olaf mentioned?
Sign in to comment