Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Issue with SQL Statement

Author  Topic 

jauner
Starting Member

19 Posts

Posted - 2010-01-13 : 16:06:35
I have the following sql query:

select jobtran.trans_date
,job.job
,job.suffix
,job.item
,jobtran.wc
,jobtran.qty_complete as Gross_qty
,GAI_Previous_Job_Info.qty_complete as Net_Qty
,GAI_Previous_Job_Info.unit_weight
,run_hrs_t_mch
from jobroute,job,GAI_Previous_Job_Info,jobtran
where jobtran.wc BETWEEN @WCStart and @WCEND and jobtran.trans_date BETWEEN @PStartingTranDate and @PEndingTranDate
and jobroute.job = job.job and jobroute.suffix = job.suffix
and jobtran.job = job.job and jobtran.suffix = job.suffix
and GAI_Previous_Job_Info.job = jobroute.job and GAI_Previous_Job_Info.Suffix = jobroute.Suffix - 1
and run_hrs_t_mch > .000
order by jobtran.wc


What I am trying to do in the report is this:

List each Item with Gross_Qty and Net_Qty and run_hrs_t_mch (Machine Run Time)

The problem I am having is I get net_qty multiple times so if there are 5 jobtran records for a job I get the same net_qty 5 times.

I understand why it is happening but I dont know if there is a way to only show that field the first time and not show it the rest for the same job and suffix.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-01-13 : 16:47:12
Can you provide table structure, sample data and expected result for that sample data?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-14 : 00:00:59
quote:
Originally posted by jauner

I have the following sql query:

select jobtran.trans_date
,job.job
,job.suffix
,job.item
,jobtran.wc
,jobtran.qty_complete as Gross_qty
,GAI_Previous_Job_Info.qty_complete as Net_Qty
,GAI_Previous_Job_Info.unit_weight
,run_hrs_t_mch
from jobroute,job,GAI_Previous_Job_Info,jobtran
where jobtran.wc BETWEEN @WCStart and @WCEND and jobtran.trans_date BETWEEN @PStartingTranDate and @PEndingTranDate
and jobroute.job = job.job and jobroute.suffix = job.suffix
and jobtran.job = job.job and jobtran.suffix = job.suffix
and GAI_Previous_Job_Info.job = jobroute.job and GAI_Previous_Job_Info.Suffix = jobroute.Suffix - 1
and run_hrs_t_mch > .000
order by jobtran.wc


What I am trying to do in the report is this:

List each Item with Gross_Qty and Net_Qty and run_hrs_t_mch (Machine Run Time)

The problem I am having is I get net_qty multiple times so if there are 5 jobtran records for a job I get the same net_qty 5 times.

I understand why it is happening but I dont know if there is a way to only show that field the first time and not show it the rest for the same job and suffix.



This is a presentataion issue and needs to be addressed at your front end. If this is for a reporting purpose, you can very well achieve this at front end using 'supress duplicates' or 'hide duplicate' property of relevant cell. which reporting tool are you using by the way?
Go to Top of Page
   

- Advertisement -