Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Have some troubles to understand when the use of these functions are needed.
From the dual example in the manual the dual is kind of a mapping?
For the Only I can follow the examples in the manual but I have seen it used many times in the forum answers and can't follow it's impact.
You use dual() when you need both a text and a numeric representation of a value. For instance, maybe you have a priority field.
High
Medium
Low
That's great for display, but not good for sorting, or taking the max(Priority), that kind of thing. So we might instead define it like this:
LOAD dual(Text,Number) as Priority
INLINE [
Text,Number
High,3
Medium,2
Low,1
];
Now, there might be other and even better ways to handle this particular example, but that's kind of the idea.
Dates WOULD be a very good example if they didn't have their own format. A date has a text representation like 'May 6, 2010', and also a numeric represenation, 40304. Normally, you want to see the text version, but you often want to sort and do mathematical manipulation using the underlying numeric, such as adding days to get a new date. Dual() makes some other sort of field behave similarly, where the text representation is what is normally displayed, but there's still a number in there that you can sort by and manipulate mathematically.
Hi,
As you said Dual is a Kind of Mapping.
Dual function Is much usefull when u want to represent a String as a Numeric then we use this.
Only Function :
If expression over a number of records, as defined by a group by clause, contains only one numeric value, that value is returned. Else, NULL is returned.
Regards,
Ajay
You use dual() when you need both a text and a numeric representation of a value. For instance, maybe you have a priority field.
High
Medium
Low
That's great for display, but not good for sorting, or taking the max(Priority), that kind of thing. So we might instead define it like this:
LOAD dual(Text,Number) as Priority
INLINE [
Text,Number
High,3
Medium,2
Low,1
];
Now, there might be other and even better ways to handle this particular example, but that's kind of the idea.
Dates WOULD be a very good example if they didn't have their own format. A date has a text representation like 'May 6, 2010', and also a numeric represenation, 40304. Normally, you want to see the text version, but you often want to sort and do mathematical manipulation using the underlying numeric, such as adding days to get a new date. Dual() makes some other sort of field behave similarly, where the text representation is what is normally displayed, but there's still a number in there that you can sort by and manipulate mathematically.