Re: Extremely complicated problem :(

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/12/04


Date: Thu, 12 Aug 2004 22:39:33 +0200

On Thu, 12 Aug 2004 11:11:02 -0700, zeyneddine wrote:

>Here's what I need to figure out from the following tables: I need to get -
>by Visit_id - the CPT4_code_id, cpt4_description (table - Claims_detail) and
>their associated charges, payments and adjustments + the payer name
(snip)

Hi zeyneddine,

What makes this problem complicated is that you provide lots of irrelevant
information (many of the columns in the DDL posted bear no relevance to
the problem), while at the same time omitting info that should have been
there, like constraints (you do have them, I hope) or a set of sample data
and expected output that might help peoplue not familiar with your line of
business understand what you're trying to achieve.

If you do want help writing the query, please provide the following info:
1. Table structure, posted as DDL (that is: CREATE TABLE statements,
complete with all constraints, but please omit columns that are irrelevant
to your question);
2. Sample data that is illustrative (*) of your problem. Please post the
sample data as INSERT statements that I can copy and paste into Query
Analyzer - otherwise, I can't test my solutions;
3. Expected output, based on the sample data given;
4. A description of the actual business problem you're trying to solve.

>As you can see, trans_detail.charge_id=charges.charge_id and
>charges.hin=network_payers.hin

No, that's something I can't see. I'm not familiar with your business and
you didn't post the FOREIGN KEY constraint that would have made this
obvious. See what I mean?

>Now the query to get the first part is:
>
>Select source_id, paid_amt, adj_amt, amt, service_item_id, cpt4_code_id,
>service_item_desc_40
>FROM trans_detail, charges
>Where trans_detail.charge_id=charges.charge_id
>AND paid_amt IS NOT NULL
>AND paid_amt > 0
>ORDER by source_id
>
>I am not even sure if thats right.

If you're not sure if that's right, wouldn't it be a good idea to test it
first? If it gets you the first part, you *know* it's right, if it
doesn't, you *know* it's wrong AND you can tell us where this query
produces output you don't want. Either way, it would be easier for us to
help you.

> Problem is how to relate to the
>Network_charts table. I am thinking of writing a subquery using the "hin"
>values of both the Charges and the Network_charts table.
>
>Can someone please assist me with that? PLEASE!!!

Without sample data and expected output, I'm afraid I have no idea how to
relate the network_charts table either.

Best, Hugo

-- 
(Remove _NO_ and _SPAM_ to get my e-mail address)


Relevant Pages

  • Re: UDF and SQL2000 - Why doesnt this work?
    ... Basically This is what I want to do - I have created a query ... as DDL (i.e. CREATE TABLE statements; ... Sample data that illustrates the problem, ... Expected output from the sample data supplied; ...
    (microsoft.public.sqlserver.programming)
  • Rare Query?
    ... Anybody please help me with this query. ... my table is ddl is: ... The expected output should be: ...
    (microsoft.public.sqlserver.programming)
  • Re: Counting consecutive dates
    ... >ideas as to how I can accomplish this. ... Without table structure, sample data and expected output, I'll have to ... The following query will find first and last date of each ...
    (microsoft.public.sqlserver.programming)
  • Re: How to synch up values from multiple tables into a single row
    ... The expected output, based on the sample data provided. ... any SQL code you are already using, ... getting from it (if it's an error message: ...
    (microsoft.public.sqlserver.programming)
  • Re: Calculation problem
    ... >However, for some reason, I am coming up with some wacky values when I try ... Expected output from the sample data. ...
    (microsoft.public.sqlserver.server)