Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queryBuilder =
- """select PID, test_sname, test_value, units, ref_range, entry_date from labs
- where PID=%s and (test_sname='want' or test_sname='want2') and entry_date in
- (select entry_date from labs where PID=%s and test_sname in ('want', 'want2')
- group by entry_date having count(*) = 2)
- order by entry_date limit 10;""" % (pid, pid)
- PID |test_sname |test_value |units |ref_range |entry_date
- 10000000 | want | 33 | U/L | 4-40 | 2008-01-01 01:01:01
- 10000000 | want2 | 98.34 | | | 2008-01-01 01:01:01
- 10000000 | NA1 | 6 | % | 4.0-6.5 | 2008-01-01 01:01:01
- 10000000 | NA2 | 40 | mg/dL | 70-110 | 2008-01-01 01:01:01
- 10000000 | NA2 | 40 | mg/dL | 70-110 | 2008-01-02 01:01:01
- 10000000 | want | 33 | U/L | 4-40 | 2008-01-02 01:01:01
- 10000000 | want2 | 98.34 | | | 2008-01-02 01:01:01
- 10000000 | NA1 | 6 | % | 4.0-6.5 | 2008-01-02 01:01:01
- 10000000 | NA2 | 40 | mg/dL | 70-110 | 2008-01-02 01:01:01
- 10000000 | NA2 | 40 | mg/dL | 70-110 | 2008-01-02 01:01:01
- PID |test_sname |test_value |units |ref_range |entry_date
- 10000000 | want | 33 | U/L | 4-40 | 2008-01-01 01:01:01
- 10000000 | want2 | 98.34 | | | 2008-01-01 01:01:01
- 10000000 | want | 33 | U/L | 4-40 | 2008-01-02 01:01:01
- 10000000 | want2 | 98.34 | | | 2008-01-02 01:01:01
- PID |test_sname |test_value |units |ref_range |entry_date
- 11111111 | want | 33 | U/L | 4-40 | 2009-10-26 07:25:00
- 11111111 | want2 | 98.34 | | | 2009-10-26 07:25:00
- 11111111 | want | 189 | U/L | 135-371 | 2009-10-26 07:25:00
- 11111111 | NA1 | 50 | % | 4.0-6.5 | 2009-10-26 07:25:00
- 11111111 | NA2 | 40 | mg/dL | 70-110 | 2009-10-26 07:25:00
- 11111111 | NA3 | 84.55 | | | 2009-10-26 07:25:00
- 11111111 | NA4 | 4.5 | thou/uL | 3.9-10.7 | 2009-10-26 07:25:00
- 11111111 | NA5 | 14.6 | g/dL | 14.0-18.1 | 2009-10-26 07:25:00
- 11111111 | NA6 | 0.96 | mg/dL | 0.70-1.50 | 2009-10-26 07:25:00
- 11111111 | want | 33 | U/L | 4-40 | 2009-10-30 07:25:00
- 11111111 | want2 | 98.34 | | | 2009-10-30 07:25:00
- 11111111 | want | 189 | U/L | 135-371 | 2009-10-30 07:25:00
- 11111111 | NA1 | 6 | % | 4.0-6.5 | 2009-10-30 07:25:00
- 11111111 | NA2 | 40 | mg/dL | 70-110 | 2009-10-30 07:25:00
- 11111111 | NA3 | 84.55 | | | 2009-10-30 07:25:00
- 11111111 | NA4 | 4.5 | thou/uL | 3.9-10.7 | 2009-10-30 07:25:00
- 11111111 | NA5 | 14.6 | g/dL | 14.0-18.1 | 2009-10-30 07:25:00
- 11111111 | NA6 | 0.96 | mg/dL | 0.70-1.50 | 2009-10-30 07:25:00
- This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
Add Comment
Please, Sign In to add comment