我试图通过查询获得一些结果,范围从-50到+50。现在根据我需要在栏目评论中有价值的范围。
条件是
>=-50 and < -30 = very negative
=< -30 and < -10 = negative
=< -10 and < +10 = neutral
=< +10 and < +30 = positive
=< +30 and < +50 = very positive
我想要获得的输出是:
range comment
-45 very negative
-20 negative
我可以获得价值,如何根据它设置评论。
答案 0 :(得分:1)
您的查询是:
SELECT * FROM your_table WHERE range BETWEEN -50 AND 50;
答案 1 :(得分:1)
您可以使用CASE语法。
udf[String, String]((session_user_id:String)...
答案 2 :(得分:0)
这听起来像是要使用SELECT range,
CASE WHEN range BETWEEN -50 AND -30 THEN 'very negative'
WHEN range BETWEEN -30 AND -10 THEN 'negative'
WHEN range BETWEEN -10 AND 10 THEN 'neutral'
WHEN range BETWEEN 10 AND 30 THEN 'positive'
WHEN range BETWEEN 30 AND 50 THEN 'very positive'
END AS comment
FROM yourTable
表达式:
<?php
$workid = @trim(stripslashes($_POST['workid']));
$customerid = @trim(stripslashes($_POST['cusomterid']));
$file = file('WEBDATA.csv');
?>
<table border="1">
<tr>
<td> Worksheet ID </td>
<td> Customer ID</td>
<td> Device Name</td>
<td> Serial Number</td>
<td> Manufacturer</td>
<td> Expected Price </td>
<td> Gross Final Price </td>
<td> Repairing status </td>
<tr>
<?php
foreach($file as $line){
list($workid,$customerid,$devicename,$devicesnumber,$manufactured,$offer,$grosspay,$status)= explode(";",$line);
?>
<td><?php echo "$workid" ?></td>
<td><?php echo "$customerid" ?> </td>
<td><?php echo "$devicename" ?> </td>
<td><?php echo "$devicesnumber" ?> </td>
<td><?php echo "$manufactured" ?> </td>
<td><?php echo "$offer" ?> </td>
<td><?php echo "$grosspay" ?> </td>
<td><?php echo "$status" ?> </td>
<?php } ?>
</table>