Back to questions

Cards Issued Difference JPMorgan Chase SQL Interview Question

Cards Issued Difference

JPMorgan Chase SQL Interview Question

Your team at JPMorgan Chase is preparing to launch a new credit card, and to gain some insights, you're analyzing how many credit cards were issued each month.

Write a query that outputs the name of each credit card and the difference in the number of issued cards between the month with the highest issuance cards and the lowest issuance. Arrange the results based on the largest disparity.

Table:

Column NameType
card_namestring
issued_amountinteger
issue_monthinteger
issue_yearinteger

Example Input:

card_nameissued_amountissue_monthissue_year
Chase Freedom Flex5500012021
Chase Freedom Flex6000022021
Chase Freedom Flex6500032021
Chase Freedom Flex7000042021
Chase Sapphire Reserve17000012021
Chase Sapphire Reserve17500022021
Chase Sapphire Reserve18000032021

Example Output:

card_namedifference
Chase Freedom Flex15000
Chase Sapphire Reserve10000

Chase Freedom Flex's best month was 70k cards issued and the worst month was 55k cards, so the difference is 15k cards.

Chase Sapphire Reserve’s best month was 180k cards issued and the worst month was 170k cards, so the difference is 10k cards.

The dataset you are querying against may have different input & output - this is just an example!

Input

(PostgreSQL)

Output