Database schema:

CREATE TABLE divisions (
	division TEXT NOT NULL -- example: ['D1', 'B1'],
	name TEXT -- example: ['Division 1A', 'Bundesliga'],
	country TEXT -- example: ['Deutschland', 'Belgium'],
	PRIMARY KEY (division)
)


CREATE TABLE matchs (
	"Div" TEXT -- example: ['D1', 'B1'],
	"Date" DATE -- example: ['2020-08-08', '2020-08-09'],
	"HomeTeam" TEXT -- example: ['Antwerp', 'Club Brugge'],
	"AwayTeam" TEXT -- example: ['Mouscron', 'Charleroi'],
	"FTHG" INTEGER -- example: ['0', '1'],
	"FTAG" INTEGER -- example: ['0', '1'],
	"FTR" TEXT -- example: ['A', 'D'],
	season INTEGER -- example: ['2020', '2021'],
	CONSTRAINT fk_matchs_divisions FOREIGN KEY("Div") REFERENCES divisions (division)
)

Question: From the Spanish LaLiga division in the 2017 season, which team won the most times as a local team and by what percentage?
Evidence: local team refers to HomeTeam; Spanish means belong to the country = 'Spain'; LaLiga is a name of division; won as a local team refers to FTR = 'H', where H stands for home victory; DIVIDE(COUNT(Div where name = 'LaLiga', country = 'Spain', season = 2017, FRT = 'H'), COUNT(Div where name = 'LaLiga', country = 'Spain', season = 2017)) as percentage;

SQL:
SELECT T1.HomeTeam HWHT , CAST(COUNT(CASE WHEN T1.FTR = 'H' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(HomeTeam) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'LaLiga' AND T2.country = 'Spain' AND T1.season = 2017