Check

an anonymous user · September 16, 2021 · SQL
-- create a table
CREATE TABLE account (
  customer varchar(10),
  balance INT
);
-- insert some values
INSERT INTO account VALUES ('Ryan', 123);
INSERT INTO account VALUES ('Joanna',123);
INSERT into account values( 'Amdm', 23);
-- fetch some values
-- SELECT f.a, count(f.a) from students f, students s where f.b<=s.b group by f.a

select A.customer, count(B.customer)
  from account A, account B
  where A.balance <= B.balance
  group by A.customer;

select A.customer,1+count(B.customer)
  from account A, account B
  where A.balance < B.balance
  group by A.customer;

Comments

Please sign up or log in to contribute to the discussion.