Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
i need the sorting order for the particular range
please find the attachements
!
select RangeOfsales from table group by RangeOfsales order by
case
when RangeOfSales = Less than 1K' then 1
when RangeOfSales = '1k-2k' then 2
when RangeOfSales = '3k-5k' then 3
end asc;
how to use the abvoe query in QV. (in DB executing this query givig me the proper sort order, i need to take it to QV)
consider there are one or more columns like RangeOfsales to sort . ex: RangeofPrices ....
requierd help
load only(RangeOfsales ),pick(match(RangeOfsales ,'Less than 1K','1k-2k','3k-5k'),1,2,3) as grouping from (path of file) group by RangeOfsales;
including more fields on group by like RangeofPrices will not give right results.
ex:
rangeofsales, rangeofprices
1k-2k, 3k-5k
1k-2k,4k-8k
then output will only show
rangeofsales, rangeofprices,grouping
1k-2k, 3k-5k , 1
so is there any alternative way to get the sort?
Simply do like this
Load if(sales>1000 and sales<2000, '1k-2k',
if(sales>2000 and sales<5000, '2k-5k',
if(sales>5000 and sales<10000, '5k-10k',
))) as range.
you could use dual like Robert already suggested
how do you create your ranges ?
I am assuming with a nested if so you could do something like this
if (Sales < 1000, dual('less than 1k ',1),
if(Sales <= 2000, dual('1k-2k ',2),
if(Sales <= 5000, dual('3k-5k ',3),
.......
and then you apply a sort based on the numeric value of the field