Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

A newbie question

$
0
0

Hi everyone.

I have a question, which i can't solve. Here are 2 tables:

Customers:

CityCode

CustomerID

AccountID

Tel Aviv

1

1

Jerusalem

2

1

Beer Sheva

1

2

Tel Aviv

3

2

Jerusalem

4

3

Hertzelia

5

4

Credit_Cards:

Credit_card_ind

Credit 

AccountID 

0 (no card)

1000

1

1 (there's a card)

5000

2

0

2300

3

1

30000

4

There are 5 questions, but with a catch:

1) All the customers with overall credit over 5000

2) No customers if one of their accountsID has no credit card

3) All of the accountIDs that have credit below 30000

4) No accounts where one (or more) customers is from Jerusalem

5) All the accounts that have more than 1 customer.

The catch is all of these have to be in one query, but each is a separate group.

I started like this, but honestly, have no idea how to do it:

Select *, CASE when b.Credit > 5000 then ‘Condition 1’
                    When Credit_card_ind = 1 then ‘Condition 2’
        When Credit < 30000 then ‘Condition 3’
        When a,CityCode is not Jerusalem then ‘Condition 4’
        When 
From customers c 
Inner join credit_cards cc on c.AccountID = cc.AccountID

Thank you in advance!


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>