Home > database >  What's the difference between these two kinds of writing? The book recommend the second answer
What's the difference between these two kinds of writing? The book recommend the second answer

Time:09-24

1.
SELECT
COUNT (CASE WHEN hanbai_tanka & lt;=1000 THEN hanbai_tanka ELSE NULL END) AS low_price,
The COUNT (CASE WHEN hanbai_tanka BETWEEN 1001 AND 3000 THEN hanbai_tanka ELSE NULL END) AS mid_price,
COUNT (CASE WHEN hanbai_tanka & gt;=3001 THEN hanbai_tanka ELSE NULL END) AS high_price
The FROM Shohin;
2.
SELECT
The SUM (CASE WHEN hanbai_tanka & lt;=1000 THEN 1 ELSE 0 END) AS low_price,
The SUM (CASE WHEN hanbai_tanka BETWEEN 1001 AND 3000 THEN 1 ELSE 0 END) AS mid_price,
The SUM (CASE WHEN hanbai_tanka & gt;=3001 THEN 1 ELSE 0 END) AS high_price
The FROM Shohin;
The result is the correct

CodePudding user response:

Feeling nothing too big difference, you can compare the two methods of execution efficiency

CodePudding user response:

1=1 right, of course, which is not recommended, but which should be used

CodePudding user response:

Right, the upstairs.
  • Related