Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Skip the ticket, Chat with Qlik Support instead for instant assistance.
cancel
Showing results for 
Search instead for 
Did you mean: 
yanivbm88
Creator
Creator

SQL WHERE condition by Year (In Load Script)

Hi,

I am uploading data through ODBC connection, with SQL SELECT statement.

I want to add a WHERE clause by year (Year >=2017).

My dates are formatted as string ('DD.MM.YY'). Therefore I will probably need to use 'Right' function (But I'm open to other ideas as well).

What will be a valid syntax for this condition?

I repeat, I am not referring to an upload from a Qvd file.

Thanks in advance.

1 Solution

Accepted Solutions
sibusiso90
Creator III
Creator III

With preseeding load you will bring in all your data then limit it within QlikView.

LOAD

     *

Where Right(FieldName,2)<17;

SQL

Select *

from mytable;

View solution in original post

8 Replies
sibusiso90
Creator III
Creator III

Load *

SQL

Select

     Top 10

     *

From

     MyTable

Where

     Right(fieldname,2) >= '17';

or you can use preseeding load if your table is not too big.

sibusiso90
Creator III
Creator III

With preseeding load you will bring in all your data then limit it within QlikView.

LOAD

     *

Where Right(FieldName,2)<17;

SQL

Select *

from mytable;

yanivbm88
Creator
Creator
Author

Hi Sibusiso,

Below is my script. I get a 'Connector Reply Error'.

ReferenceLines:

SQL SELECT *

FROM "SCM_Reference_Data"."Lines"

WHERE Right(CreationDate,2)>='17';

If I upload  the exact same script (below) without the WHERE statement, it works fine.

ReferenceLines:

SQL SELECT *

FROM "SCM_Reference_Data"."Lines";

sibusiso90
Creator III
Creator III

Then let's use the second option,

Load

     *

where right(CreationDate,2)>=17;

SQL SELECT *

FROM "SCM_Reference_Data"."Lines";

yanivbm88
Creator
Creator
Author

My table is very big, and I want to avoid uploading it all for upload time reducing purposes

yanivbm88
Creator
Creator
Author

My table is very big, and I want to avoid uploading it as a whole for time reducing purposes

sibusiso90
Creator III
Creator III

I haven't seen the error and I can't replicate it on my machine. With my data, it works with the same syntax.

This is what I used to try and replicate your problem still can't get your error.

Ref:

sql

SELECT [IssueID]

      ,[InstanceID]

      ,[StartDate]

      ,[Origin]

  FROM [HelpDesk].[dbo].[hdIssues]

  where left(StartDate,4) >='2015';

Aurelien_Martinez
Partner - Specialist
Partner - Specialist

With SQL Server :

SQL

   Select

     *

   FROM myTable

   WHERE YEAR(myDate) >= 2017

Oracle :

SQL

   Select

     *

   FROM myTable

WHERE EXTRACT(YEAR FROM myDate) >= 2017

Help users find answers! Don't forget to mark a solution that worked for you!