crafuse
asked on
Process results of SQL query
Experts,
The following is an example of a dynamic sql query that is sent by my Access 2003 app to SQL Server.
I then take the results and throw them into an Excel file. However, I would like to process the results
a little further to do the following:
1. for any record in the qdocall table that ONLY has doctypes being excluded do the following:
Return only 1 record in total, and give doctype value = 'No Due Date'.
2. for any record in qdocall that has both excluded and other doctype values do the following:
Return only 1 record in total for all excluded doctype records, and give doctype value = 'No Due Date'
Return all other records with doctype value not among those excluded.
3. This is well beyond my abilities and am hoping that a solution will include some code. Also,
my application takes the querydef recordset and ports it immediately into Excel. I would be open,
however, to a solution that requires the recordset first being put into a tmp table on the
local machine, with processing then ocurring at that point.
4. I'd be more than happy to split this question into chunks as we go along - I could be wrong,
but it seems to me this is a bit tricky.
Select rtrim(qclient.clname) as 'Client Name',
qclient.clinum as 'Client Number',
qmatter.matnum as 'Matter Number',
qdocall.doctyp as 'Docket Type'
from (qclient inner join qmatter on qclient.clinum = qmatter.clinum)
left outer join qdocall
on qmatter.clinum = qdocall.clinum
and qmatter.matnum = qdocall.matnum
and qdocall.doctyp not like '%Bring Forward%'
and qdocall.doctyp not like '%Exam. Ackn. by C.I.P.O%'
and qdocall.doctyp not like '%TM Direct Renewal Cert%'
and qdocall.doctyp not like '%Examination Requested%'
and qdocall.doctyp not like '%Filing Certificate%'
and qdocall.doctyp not like '%Formal Confirmation%'
and qdocall.doctyp not like '%ID Assoc. Status%'
and qdocall.doctyp not like '%ID Direct Status%'
and qdocall.doctyp not like '%ID Renewal Cert%'
and qdocall.doctyp not like '%Issue Fee Paid%'
and qdocall.doctyp not like 'Letters Patent%'
and qdocall.doctyp not like '%Patent Issued%'
and qdocall.doctyp not like '%P.O. Exam Ackn%'
and qdocall.doctyp not like '%Receipt of IPER/IPRP%'
and qdocall.doctyp not like '%Rec%d Letters Patent%'
and qdocall.doctyp not like '%Rcpt. of Written Opinion%'
and qdocall.doctyp not like 'Search Report'
and qdocall.doctyp not like '%Search Report/Written Opinion%'
and qdocall.doctyp not like 'Status'
and qdocall.doctyp not like '%Status Docket(Central)%'
and qdocall.doctyp not like '%TM Assoc. Filing Cert%'
and qdocall.doctyp not like '%TM Assoc. Status%'
and qdocall.doctyp not like '%TM Direct Filing Cert%'
and qdocall.doctyp not like '%TM Direct Status%'
where qclient.clinum in (142);
Thanks In Advance!
crafuse
The following is an example of a dynamic sql query that is sent by my Access 2003 app to SQL Server.
I then take the results and throw them into an Excel file. However, I would like to process the results
a little further to do the following:
1. for any record in the qdocall table that ONLY has doctypes being excluded do the following:
Return only 1 record in total, and give doctype value = 'No Due Date'.
2. for any record in qdocall that has both excluded and other doctype values do the following:
Return only 1 record in total for all excluded doctype records, and give doctype value = 'No Due Date'
Return all other records with doctype value not among those excluded.
3. This is well beyond my abilities and am hoping that a solution will include some code. Also,
my application takes the querydef recordset and ports it immediately into Excel. I would be open,
however, to a solution that requires the recordset first being put into a tmp table on the
local machine, with processing then ocurring at that point.
4. I'd be more than happy to split this question into chunks as we go along - I could be wrong,
but it seems to me this is a bit tricky.
Select rtrim(qclient.clname) as 'Client Name',
qclient.clinum as 'Client Number',
qmatter.matnum as 'Matter Number',
qdocall.doctyp as 'Docket Type'
from (qclient inner join qmatter on qclient.clinum = qmatter.clinum)
left outer join qdocall
on qmatter.clinum = qdocall.clinum
and qmatter.matnum = qdocall.matnum
and qdocall.doctyp not like '%Bring Forward%'
and qdocall.doctyp not like '%Exam. Ackn. by C.I.P.O%'
and qdocall.doctyp not like '%TM Direct Renewal Cert%'
and qdocall.doctyp not like '%Examination Requested%'
and qdocall.doctyp not like '%Filing Certificate%'
and qdocall.doctyp not like '%Formal Confirmation%'
and qdocall.doctyp not like '%ID Assoc. Status%'
and qdocall.doctyp not like '%ID Direct Status%'
and qdocall.doctyp not like '%ID Renewal Cert%'
and qdocall.doctyp not like '%Issue Fee Paid%'
and qdocall.doctyp not like 'Letters Patent%'
and qdocall.doctyp not like '%Patent Issued%'
and qdocall.doctyp not like '%P.O. Exam Ackn%'
and qdocall.doctyp not like '%Receipt of IPER/IPRP%'
and qdocall.doctyp not like '%Rec%d Letters Patent%'
and qdocall.doctyp not like '%Rcpt. of Written Opinion%'
and qdocall.doctyp not like 'Search Report'
and qdocall.doctyp not like '%Search Report/Written Opinion%'
and qdocall.doctyp not like 'Status'
and qdocall.doctyp not like '%Status Docket(Central)%'
and qdocall.doctyp not like '%TM Assoc. Filing Cert%'
and qdocall.doctyp not like '%TM Assoc. Status%'
and qdocall.doctyp not like '%TM Direct Filing Cert%'
and qdocall.doctyp not like '%TM Direct Status%'
where qclient.clinum in (142);
Thanks In Advance!
crafuse
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
quick question - i'm about the worst sql guy in the world, so please tell me this - how important is the order by clause in this query? does it affect the way the distinct records are managed during the output? can it be safely removed? reason I ask is that i need to know whether I should then disable the user's ability to selct other fields to order by\sort by.
thanks
thanks
>> how important is the order by clause in this query? does it affect the way the distinct records are managed during the output? can it be safely removed? reason I ask is that i need to know whether I should then disable the user's ability to selct other fields to order by\sort by. <<
Sorry, my bad, it has *no* affect other to put the rows in what I thought was a "natural" order.
Naturally you should keep the user's ability to select other sort column(s).
Sorry, my bad, it has *no* affect other to put the rows in what I thought was a "natural" order.
Naturally you should keep the user's ability to select other sort column(s).
ASKER
Sweet. Thanks again!
ASKER