Case statement customer query

时间:2016-02-12 21:41:02

标签: sql case tableau ora-00936

I am new to tableau parameters. I am trying to execute the following query but somehow it give me missing parenthesis error.

 //Code to manually set the interval of X-Axis Labels: From http://jsfiddle.net/leighking2/n9c8jx55/
        Chart.CustomScale = Chart.Scale.extend({
            draw: function () {
                var helpers = Chart.helpers;
                var each = helpers.each;
                var aliasPixel = helpers.aliasPixel;
                var toRadians = helpers.radians;
                var ctx = this.ctx,
                    yLabelGap = (this.endPoint - this.startPoint) / this.steps,
                    xStart = Math.round(this.xScalePaddingLeft);
                if (this.display) {
                    ctx.fillStyle = this.textColor;
                    ctx.font = this.font;
                    each(this.yLabels, function (labelString, index) {
                        var yLabelCenter = this.endPoint - (yLabelGap * index),
                            linePositionY = Math.round(yLabelCenter);

                        ctx.textAlign = "right";
                        ctx.textBaseline = "middle";
                        if (this.showLabels) {
                            ctx.fillText(labelString, xStart - 10, yLabelCenter);
                        }
                        ctx.beginPath();
                        if (index > 0) {
                            // This is a grid line in the centre, so drop that
                            ctx.lineWidth = this.gridLineWidth;
                            ctx.strokeStyle = this.gridLineColor;
                        } else {
                            // This is the first line on the scale
                            ctx.lineWidth = this.lineWidth;
                            ctx.strokeStyle = this.lineColor;
                        }

                        linePositionY += helpers.aliasPixel(ctx.lineWidth);

                        ctx.moveTo(xStart, linePositionY);
                        ctx.lineTo(this.width, linePositionY);
                        ctx.stroke();
                        ctx.closePath();

                        ctx.lineWidth = this.lineWidth;
                        ctx.strokeStyle = this.lineColor;
                        ctx.beginPath();
                        ctx.moveTo(xStart - 5, linePositionY);
                        ctx.lineTo(xStart, linePositionY);
                        ctx.stroke();
                        ctx.closePath();

                    }, this);

                    each(this.xLabels, function (label, index) {
                        //======================================================
                        //apply the filter to the index if it is a function
                        //======================================================
                        if (typeof this.labelsFilter === "function" && this.labelsFilter(index)) {
                            return;
                        }
                        //Hack by Mike Walder to enforce X-Labels are Written horizontally
                        var xLabelRot = this.xLabelRotation;
                        this.xLabelRotation = 0;
                        //End of Hack
                        var xPos = this.calculateX(index) + aliasPixel(this.lineWidth),
                            // Check to see if line/bar here and decide where to place the line
                            linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth),
                            //Mike Walder: isRotated nees original Roation Value to display the X-Label in the RollOver Area of a Datapoint
                            isRotated = true;(xLabelRot > 0);

                        ctx.beginPath();
                    if(this.scaleShowVerticalLines){
                            if (index > 0) {
                                // This is a grid line in the centre, so drop that
                                ctx.lineWidth = this.gridLineWidth;
                                ctx.strokeStyle = this.gridLineColor;
                            } else {
                                // This is the first line on the scale
                                ctx.lineWidth = this.lineWidth;
                                ctx.strokeStyle = this.lineColor;
                            }
                            ctx.moveTo(linePos, this.endPoint);
                            ctx.lineTo(linePos, this.startPoint - 3);
                            ctx.stroke();
                            ctx.closePath();


                            ctx.lineWidth = this.lineWidth;
                            ctx.strokeStyle = this.lineColor;
                        }
                        // Small lines at the bottom of the base grid line
                        ctx.beginPath();
                        ctx.moveTo(linePos, this.endPoint);
                        ctx.lineTo(linePos, this.endPoint + 5);
                        ctx.stroke();
                        ctx.closePath();

                        ctx.save();
                        ctx.translate(xPos, (isRotated) ? this.endPoint + 12 : this.endPoint + 8);
                        ctx.rotate(toRadians(this.xLabelRotation) * -1);

                        //Mike Walder added center here, because it looks better if the label designator is in the center of the smal line
                        ctx.textAlign = "center";
                        ctx.textBaseline = (isRotated) ? "middle" : "top";
                        ctx.fillText(label, 0, 0);
                        ctx.restore();

                    }, this);

                }
            }
        });

Chart.types.Line.extend({
            name: "LineAlt",
            initialize: function (data) {
                //======================================================
                //ensure the new option is part of the options
                //======================================================
                this.options.labelsFilter = data.labelsFilter || null;
                Chart.types.Line.prototype.initialize.apply(this, arguments);

            },
            buildScale: function (labels) {
                var helpers = Chart.helpers;
                var self = this;

                var dataTotal = function () {
                    var values = [];
                    self.eachPoints(function (point) {
                        values.push(point.value);
                    });

                    return values;
                };
                var scaleOptions = {
                    // Mike Walder: added this configuration option since it is overridden in the new code
                    scaleShowVerticalLines: this.options.scaleShowVerticalLines,
                    templateString: this.options.scaleLabel,
                    height: this.chart.height,
                    width: this.chart.width,
                    ctx: this.chart.ctx,
                    textColor: this.options.scaleFontColor,
                    fontSize: this.options.scaleFontSize,
                    //======================================================
                    //pass this new options to the scale object
                    //======================================================
                    labelsFilter: this.options.labelsFilter,
                    fontStyle: this.options.scaleFontStyle,
                    fontFamily: this.options.scaleFontFamily,
                    valuesCount: labels.length,
                    beginAtZero: this.options.scaleBeginAtZero,
                    integersOnly: this.options.scaleIntegersOnly,
                    calculateYRange: function (currentHeight) {
                        var updatedRanges = helpers.calculateScaleRange(
                        dataTotal(),
                        currentHeight,
                        this.fontSize,
                        this.beginAtZero,
                        this.integersOnly);
                        helpers.extend(this, updatedRanges);
                    },
                    xLabels: labels,
                    font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily),
                    lineWidth: this.options.scaleLineWidth,
                    lineColor: this.options.scaleLineColor,
                    gridLineWidth: (this.options.scaleShowGridLines) ? this.options.scaleGridLineWidth : 0,
                    gridLineColor: (this.options.scaleShowGridLines) ? this.options.scaleGridLineColor : "rgba(0,0,0,0)",
                    padding: (this.options.showScale) ? 0 : this.options.pointDotRadius + this.options.pointDotStrokeWidth,
                    showLabels: this.options.scaleShowLabels,
                    display: this.options.showScale
                };

                if (this.options.scaleOverride) {
                    helpers.extend(scaleOptions, {
                        calculateYRange: helpers.noop,
                        steps: this.options.scaleSteps,
                        stepValue: this.options.scaleStepWidth,
                        min: this.options.scaleStartValue,
                        max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth)
                    });
                }

                //======================================================
                //Use the new Custom Scal that will make use of a labelsFilter function
                //======================================================
                this.scale = new Chart.CustomScale(scaleOptions);
            }
        });

How should I fix it

1 个答案:

答案 0 :(得分:0)

从Tableau中获取最大价值的一般建议 - 避免将SQL输入Tableau。这适用于数据连接中的自定义SQL或在计算字段中调用RAW SQL函数。

这并不意味着这些功能没有有效和重要的用途,但它们相对较少。大多数情况下,这表明某人正在恢复手工编码的SQL,因为他们已经了解它,而不是花时间学习Tableau。这种方法通常不会带来最好的结果。

如果您发现Tableau功能与您尝试实现的概念相对应,您通常会以更高的灵活性和效率完成相同的结果。简而言之,让Tableau负责为您的查询生成特定的SQL,除非您没有其他选择。

Tableau对不同的过滤,截断,格式化和绘制日期值的方式提供了各种支持。

尝试直接连接到桌面A,并将create_date放在过滤器架上,并显示快速过滤器,以便轻松调整过滤条件。根据您是否将create_date视为过滤器架上的连续或离散字段,您将获得不同类型的选择。根据您是否选择将create_date截断为日,月,季度或年份,您将始终获得不同的结果。

在您的情况下,我会尝试将create_date视为过滤器架上的连续(绿色)确切日期(不截断),然后使用开始日期,范围或句点快速过滤器。您可以通过单击过滤器右上角的黑色三角形来调整快速过滤器类型。

如果内置过滤器都不适合您的需要,您可以定义一个引用您的参数的布尔值计算字段,并确定是否应该包含日期,然后将该字段放在过滤器架上。

您在过滤器架上放置的内容会影响生成的SQL的where和having子句