Do subqueries work on MYSQL?
ngano gi-group mani bai? wa pa kau ko ka-g sa concept sa group by. nsa d i mahitabo if dili i-group by?Originally Posted by kyle_nexus
di ba kinahanglan nimo igroup bai basta naa ka aggregate functions?
yes subqueries works in mySQLOriginally Posted by kobmat
unsa na version bai... last time i tried on mysql 3.23 it does not work
SELECT dept, SUM(salary) AS Expr1Originally Posted by red_colt
FROM table1
WHERE (dept = 'IT')
GROUP BY dept
bai redcolt,
in the above sql statement, group by is a required clause because it includes an aggregate
function SUM for salary field. Remember it selects two columns dept and salary field is already SUM up meaning the result for salary field is only 1 Row (kay naka sum naman) , with this you need also to GROUP the dept field para 1 row ra pud ang result. If dili naka group ang dept you will encounter an error with the statement.
im using the GNU version 5 of mySQL (just check mysql.com) . ngita lagi ko higher version pero naay daghan pirated or you have to buy the licenced medyo mahal.Originally Posted by kobmat
bai we encourage you and ur friend to answer the lastest sql quiz above para ma mag move mi
thanks
Sakto ni bai?
SELECT MONTH(ORDERS_H.TRANSACTION_DATE) AS MON,
CUSTOMER.CUSTOMER_NAME,
SUM(ORDERS_D.SELLING_PRICE) AS TOTAL_PURCHASES
FROM ORDERS_D, ORDERS_H, CUSTOMER
WHERE ORDERS_D.RECORD_NO = ORDERS_H.RECORD_NO AND
ORDERS_H.CUSTOMER_CODE = CUSTOMER.CUSTOMER_CODE
GROUP BY MON, ORDERS_H.CUSTOMER_CODE;
bai kobmat, let have otis validate your answer kay siya man ang ni post the question...Otis asa naman ka ?Originally Posted by kobmat
part post na sa imong next SQL question..ika number 5 na
Sorry for the late reply, I've been busy sa work.Originally Posted by kobmat
Yes, I believe that's correct.. perowouldn't work in MS SQL Server.GROUP BY MON
GROUP BY MONTH(ORDERS_H.TRANSACTION_DATE) would work or you could create a derived table having MON as a column ;D
Similar Threads |
|