FLAG 'Y' to first matched condition in SQL Server

Table A : ID AMOUNT Order ————————- 1 100 1 1 300 2 1 320 3 2 100 1 2 200 2 2 423 3 2 613 4 3 112 1 3 218 2 3 290 3 3 480 4 Expected Output : Table A : ID AMOUNT Order Flag —————————— 1 100 1 1… Read More FLAG 'Y' to first matched condition in SQL Server

Trying to understand why IS NOT NULL is necessary at end of query and case statement in SQL

I’m working on a query in DataCamp SQL and I don’t understand the ending to this query: SELECT season, date, home_goal, away_goal FROM matches_italy WHERE — Exclude games not won by Bologna CASE WHEN hometeam_id = 9857 AND home_goal > away_goal THEN ‘Bologna Win’ WHEN awayteam_id = 9857 AND away_goal > home_goal THEN ‘Bologna Win’… Read More Trying to understand why IS NOT NULL is necessary at end of query and case statement in SQL

Tsql Select CASE

i need help in writing tsql select statement for my update: Existing SQL update statement: Update etl.dbo.SVRSummaryDataStage SET Location = CASE WHEN Location IN (‘131200′,’131400′,’131500′,’132400’) THEN ‘131200’ WHEN Location IN (‘130600′,’131600′,’131700′,’131800’) THEN ‘130600’ WHEN Location IN (‘130700′,’130800′,’130900′,’131100′,’131300′,’131900′,’132200’) THEN ‘130700’ WHEN Location IN (‘130100′,’130200′,’130300’) THEN ‘130110’ WHEN Location IN (‘130400′,’130500′,’132100’) THEN ‘130120’ END WHERE Location IN… Read More Tsql Select CASE

If values in Column A are the same and other values are equal to, then put X in another column

I have something like this… FlightNum Class Seats SoldOut 10 A 0 10 B 5 10 C 15 10 D 25 I want to write a statement where FlightNum is the same, and A class has 0 seats, all rows for that FlightNum should put a "1" in the SoldOut column. FlightNum Class Seats SoldOut… Read More If values in Column A are the same and other values are equal to, then put X in another column