cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Command - Paramater and wildcard

Former Member
0 Kudos

Post Author: edy80y

CA Forum: Crystal Reports

Hi All,

I have successfully dumped an SQL into a 'Add Command' function and it returns the data exactly how i want it. But now i want to add a parameter so that i dont have to manually update the date which is referenced 8 times.

The TIME_KEY field is in this format YYYYMMDDHHMMWST (for 20/12/2007 2:30PM) = 200712201430WST

I have used LIKE '20071220%' so it returns all rows within that one date.

Now, i created a string parameter {?date) so i can enter '20071220' and i want to attach the wildcard (%) to the parameter.

If i do any of the following it doesn't work:

LIKE {?date} + '%'

LIKE {?date} || '%'

LIKE {?date} & '%'

Here is the code:

SELECT "T1"."OBJECT_ID", "T1"."TIME_KEY", (SELECT SUM("N_ANSWERED") AS "ANSWERED_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED_RING") AS "ABANDONED_RING_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED_QUEUE") AS "ABANDONED_QUEUE_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ENTERED") AS "ENTERED_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED_SHORT") AS "ABANDONED_SHORT_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ANS_IN_THRESH") AS "ANS_IN_THRESH_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED") AS "ABANDONED_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%')FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T1"WHERE "T1"."TIME_KEY" LIKE '20071220%'GROUP BY "T1"."OBJECT_ID", "T1"."TIME_KEY"ORDER BY "T1"."OBJECT_ID", "T1"."TIME_KEY"

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Post Author: yangster

CA Forum: Crystal Reports

putting the parameter within a single quote is incorrect if it is a string as it will look for a litteral reference to {?date} instead of the valueLIKE {?date} || '%'that should work np as you are con catting a string to another string with 0 to infinite number of characters followingwhat db are you using?

Former Member
0 Kudos

Post Author: fsu304

CA Forum: Crystal Reports

you have to put the wildcard character within your quotes like the following.

LIKE '{?date}%'