我正在尝试使用COALESCE函数运行配置单元查询来创建视图。但它就像扔错误一样 无法识别附近的输入('' SELECT''' realvalue' in expression specification
查询如下。请帮忙,并提出这有什么问题。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:fadingEdge="none"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.CardView
android:id="@+id/nameCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip" >
<LinearLayout
android:id="@+id/relativeLayout4"
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2.6"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="First"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size"
android:textStyle="bold" />
<TextView
android:id="@+id/Details1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
</LinearLayout >
</LinearLayout >
</android.support.v7.widget.CardView >
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip" >
<LinearLayout
android:id="@+id/relativeLayout1"
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="@+id/_Details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:gravity="start|center_vertical"
android:hint="Second"
android:padding="5dp"
android:singleLine="false"
android:textColor="@color/darkslate"
android:textColorHint="@color/darkslate"
android:textSize="16sp"
android:textStyle="normal" />
</LinearLayout >
<LinearLayout
android:id="@+id/gift"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="@+id/__Details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:gravity="start|center_vertical"
android:hint="cardview"
android:padding="5dp"
android:singleLine="false"
android:textColor="@color/darkslate"
android:textColorHint="@color/darkslate"
android:textSize="16sp"
android:textStyle="normal" />
<TextView
android:id="@+id/Details11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
</LinearLayout >
</LinearLayout >
</android.support.v7.widget.CardView >
<LinearLayout
android:id="@+id/linearScrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip" >
<LinearLayout
android:id="@+id/relativeLayout2"
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="@+id/Details21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:gravity="start|center_vertical"
android:hint="Third"
android:padding="5dp"
android:singleLine="false"
android:textColor="@color/darkslate"
android:textColorHint="@color/darkslate"
android:textSize="16sp"
android:textStyle="normal" />
<TextView
android:id="@+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:gravity="start|center_vertical"
android:hint="cardview"
android:padding="5dp"
android:singleLine="false"
android:textColor="@color/darkslate"
android:textColorHint="@color/darkslate"
android:textSize="16sp"
android:textStyle="normal" />
<TextView
android:id="@+id/Details23"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
<TextView
android:id="@+id/Details22"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:padding="5dp"
android:singleLine="true"
android:text="cardview"
android:textColor="@color/darkslate"
android:textSize="@dimen/font_normal_size_small"
android:textStyle="normal" />
</LinearLayout >
</LinearLayout >
</android.support.v7.widget.CardView >
</LinearLayout >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="5dip"
android:hint="click"
android:padding="5dip" />
</LinearLayout >
</ScrollView >
</RelativeLayout >
等。
请帮忙。错误在于使用COALESCE中的select语句。 NoViableAltException(231 @ [435:1:precedenceEqualExpression:((LPAREN precedenceBitwiseOrExpression COMMA)=&gt; precedenceEqualExpressionMutiple | precedenceEqualExpressionSingle);])
由于
答案 0 :(得分:0)
如果你需要的只是一个默认值,你可以做
CREATE VIEW IF NOT EXISTS exampledb.`ara_service` AS
SELECT T1.EntityId, T1.entityname AS EntityName,
T1.`xxx`,
T1.`yyy`,
COALESCE (T1.`aaa`, def.`realvalue` ) AS `CombinedValue`,
T1.`ddd`,
T1.`jjj`,
FROM your_table T1
CROSS JOIN (
SELECT `realvalue`
FROM exampledb.`aba_service` WHERE `id` = '333') def