Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide columns? MySQL

Tags:

mysql

hide

sum

I have a code I've made but I'd like to hide the column. So that it only shows the storeID instead of the SALARY along with it. I know I need to wrap it around in another set of brackets, but don't know where to do that. Also can anyone tell me a technique to identify where to use the brackets? Sorry, not too familiar with MySQL, but have been learning for couple of weeks now. Just finished the diagrams with Chen Notations, now the codes.

SELECT storeID, SUM(SALARY) FROM STORE
JOIN EMPLOYEE
WHERE SALARY < expenditure;

Currently it's displaying:

| storeID | |    SUM(SALARY)    |
|    1    | |    £30000         |
|    2    | |    £25000         |
|    3    | |    NOTHING        |

I want the second column SUM(SALARY) to be hidden. Thanks in advance.

EDIT: I wasn't being too clear. I needed to calculate the SALARY (sum of all salaries from each store), and find the storeID's with SALARY < expenditure.

EMPLOYEE = SALARY STORE = storeID and expenditure.

like image 657
Dembele Avatar asked Jan 17 '13 23:01

Dembele


2 Answers

SELECT StoreId
FROM
(
   SELECT storeID, SUM(SALARY) FROM STORE
   JOIN EMPLOYEE
   WHERE SALARY < expenditure
)

this should work ;)

like image 102
PatrickPirker Avatar answered Sep 19 '22 01:09

PatrickPirker


try this

    SELECT storeID  FROM STORE
    JOIN EMPLOYEE
    WHERE SALARY < expenditure;
like image 34
echo_Me Avatar answered Sep 21 '22 01:09

echo_Me