If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Group by Help!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-03, 05:41
nbison nbison is offline
Registered User
 
Join Date: Aug 2003
Posts: 6
Group by Help!

How do i get my group by to show null values as well?

At the moment the following statement will discard the NULL rows:

SELECT e.empno, e.fname, e.lname, w.location, w.buildingno, w.floorno,
w.facilityno
FROM employee e LEFT OUTER JOIN
workarea w ON e.empno = w.empno
GROUP BY w.location, w.buildingno, w.floorno, w.facilityno;

Kindly regards,

Nav

Last edited by nbison; 09-11-03 at 06:34.
Reply With Quote
  #2 (permalink)  
Old 09-11-03, 20:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
write your query so that all non-aggregate columns in the SELECT list are in the GROUP BY

with the GROUP BY that you have, the columns e.empno, e.fname, and e.lname should be involved in aggregate functions, e.g.
Code:
select count(distinct e.empno)
     , max(e.fname)
     , min(e.lname)
     , w.location, w.buildingno, w.floorno, w.facilityno
  from employee e 
left outer
  join workarea w 
    on e.empno = w.empno
group
    by w.location, w.buildingno, w.floorno, w.facilityno
this query at least makes syntactic sense, although semantically it's pretty useless

rudy
http://r937.com/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On