how insert round function

%3CLINGO-SUB%20id%3D%22lingo-sub-2594545%22%20slang%3D%22en-US%22%3Ehow%20insert%20round%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2594545%22%20slang%3D%22en-US%22%3E%3CP%3Ehi%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20am%20a%20beginner%20in%20SQL%20.%3C%2FP%3E%3CP%3EThis%20is%20my%20query%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JD2021_0-1627507773501.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299111iB1A2A4D2DA455332%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JD2021_0-1627507773501.png%22%20alt%3D%22JD2021_0-1627507773501.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20the%20result%20.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JD2021_1-1627507841884.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299113i5DF563B3138DF1C5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JD2021_1-1627507841884.png%22%20alt%3D%22JD2021_1-1627507841884.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20want%20to%20convert%20the%26nbsp%3BAnnual_premium_In%24%20to%20a%20round%20figure.%3C%2FP%3E%3CP%3EHow%20we%20can%20do%20that%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20Advance%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2594545%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAnalytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2596665%22%20slang%3D%22en-US%22%3ERe%3A%20how%20insert%20round%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2596665%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F686348%22%20target%3D%22_blank%22%3E%40JD2021%3C%2FA%3E%26nbsp%3B--%20The%20query%20below%20will%20hopefully%20help%20you%20to%20get%20started.%26nbsp%3B%20Take%20care.%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ESELECT%20age%2Cnationality%2Cmp%2C%0A%20convert(float%2Ccase%0A%20%20when%20mp%20%3D%20106%20then%20ROUND(MP*12%2F3.65%2C2)%0A%20%20when%20MP%20%3D%2079%20THEN%20ROUND(MP*12%2F3.65%2C2)%0A%20%20when%20MP%20%3D%2053%20THEN%20ROUND(MP*12%2F3.65%2C2)%0A%20%20when%20MP%20%3D%2035%20THEN%20ROUND(MP*12%2F3.65%2C2)%0A%20else%20ROUND(MP%2F3.65%2C2)%0A%20end)%20as%20Annual_Premium_In%24%0A%20FROM%20metlife..analysis%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bake13_0-1627694385112.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299645i4BB24CBD5C61F68B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bake13_0-1627694385112.png%22%20alt%3D%22bake13_0-1627694385112.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2596099%22%20slang%3D%22en-US%22%3ERe%3A%20how%20insert%20round%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2596099%22%20slang%3D%22en-US%22%3Ewhere%20can%20put%20the%20round%20function%20on%20the%20above%20mentioned%20query%20thanks%20in%20advance%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2595871%22%20slang%3D%22en-US%22%3ERe%3A%20how%20insert%20round%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2595871%22%20slang%3D%22en-US%22%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3EI%20want%20to%20convert%20the%26nbsp%3BAnnual_premium_In%24%20to%20a%20%3CSTRONG%3Eround%3C%2FSTRONG%3E%20figure.%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F686348%22%20target%3D%22_blank%22%3E%40JD2021%3C%2FA%3E%26nbsp%3B%2C%20you%20already%20used%20the%20right%20function%20name%20ROUND%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Ffunctions%2Fround-transact-sql%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EROUND%20(Transact-SQL)%20-%20SQL%20Server%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

hi guys,

 

i am a beginner in SQL .

This is my query 

JD2021_0-1627507773501.png

 

This is the result .

JD2021_1-1627507841884.png

I want to convert the Annual_premium_In$ to a round figure.

How we can do that 

Thanks in Advance

 

 

3 Replies

I want to convert the Annual_premium_In$ to a round figure.

@JD2021 , you already used the right function name ROUND

ROUND (Transact-SQL) - SQL Server | Microsoft Docs

 

 

where can put the round function on the above mentioned query thanks in advance

Hi @JD2021 -- The query below will hopefully help you to get started.  Take care.

SELECT age,nationality,mp,
	convert(float,case
		when mp = 106 then ROUND(MP*12/3.65,2)
		when MP = 79 THEN ROUND(MP*12/3.65,2)
		when MP = 53 THEN ROUND(MP*12/3.65,2)
		when MP = 35 THEN ROUND(MP*12/3.65,2)
	else ROUND(MP/3.65,2)
	end) as Annual_Premium_In$
	FROM metlife..analysis

 

bake13_0-1627694385112.png