0

i have below table

Overs    TargetRuns   0%    10 %    20 %    
10.0    15.6          8.7   11.9    20
10.1    15.9          8.9   12.1    20
10.2    16              9   12.2    20
10.3    16.1            9   12.3    20
10.4    16.3          9.1   12.4    20

my query is

SELECT * 
FROM target_table 
where 0% OR 10% OR 20% = '${wickets}' AND Overs = '${overs}'`

for overs 10.1 and 10% === 12.1 i need output as 12.1.

3
  • Overs TargetRuns 0% 10 % 20 % 10.0 15.6 8.7 11.9 20 10.1 15.9 8.9 12.1 20 10.2 16 9 12.2 20 i want output as for overs 10.1 and 10%== 12.1 output===12.1 Commented Jun 8, 2021 at 12:24
  • 1
    'i have below table' I thnk that might be your first mistake. See normalisation. Commented Jun 8, 2021 at 12:33
  • You need to quote column names which are not valid ids. Id match this regexp: [A-Z][A-Za-z0-9_]*. A name like 10% is not an id, so it must be quoted. Commented Jun 8, 2021 at 21:48

2 Answers 2

1

Maybe you need in

SELECT * 
FROM target_table 
WHERE '${wickets}' IN (`0%`, `10%`, `20%`)
  AND Overs = '${overs}'

?

Sign up to request clarification or add additional context in comments.

Comments

0

your OR condition is wrong.

SELECT * 
FROM target_table 
where (0% = '${wickets}' OR 10% = '${wickets}'  OR 20% = '${wickets}') AND Overs = '${overs}'`

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.