mysql - Getting the results Null not included -


i wanted list of persons has null values on person_discharge_date need consider create_date(get latest) name of person not show twice.

for question, how query show person_discharge_date null values based on latest create_date?

i have trouble showing values have null on person_discharge_date , vise versa.

my intake table

intaketable     intake_id|  person_id |person_discharge_date   |create_date     ---------|------------|------------------------|-----------------------     2263     |  2289      |2010-06-28 00:00:00.000 |2012-04-17 13:41:54.503     2264     |  2289      |2010-08-28 00:00:00.000 |2012-04-17 13:41:54.547     4465     |  4489      |2011-02-12 00:00:00.000 |2012-04-17 13:41:54.563     1267     |  1218      |2009-12-11 00:00:00.000 |2012-04-17 13:41:54.707     7373     |  2348      |2010-06-03 00:00:00.000 |2012-04-17 13:41:55.297     4463     |  4429      |2011-09-20 00:00:00.000 |2012-04-17 13:41:57.133     6164     |  6129      |2011-05-18 00:00:00.000 |2012-04-17 13:41:57.143     12377    |  1888      |null                    |2013-01-05 22:12:41.990     12378    |  5899      |null                    |2013-01-05 22:17:02.957     12379    |  5899      |null                    |2013-01-05 22:18:02.957 

this person table

persontable person_id|  fname     | ---------|------------| 2289     |  marge     | 4489     |  shell     | 1218     |  linkoln   | 2348     |  abe       | 4429     |  mark      | 6129     |  doom      | 1888     |  lorde     | 5899     |  braddy    | 

this query there missing because need latest create date of person, person not show twice results.

select intake_id, person_id, person_discharge_date intaketable inner join persontable pt it.person_id = pt.person_id    person_discharge_date not null 

how make query include null results on person_discharge_date

check is null in where condition said column in question saying

where person_discharge_date null 

you can use group by , max() like

select person.*, xxx.person_discharge_date  person p join ( select person_id, person_discharge_date,    max(create_date) latest intake person_discharge_date null   group person_id ) xxx on p.person_id = xxx.person_id; 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -