Need help with inner join and distinct rows
Hey Guys,
i have
1) BaseEnv Table
2) Link Table
3) BaseData Table
Link table has three columns Id,BaseEnvId,BaseDataId
the BaseEnvID is unique in the table where as BaseDataId can be repeated i.e multile rows of BaseEnv Table can point to same BaseData table row
Now i want to do BaseEnvTable inner join Link Table inner join BaseData Table and select 5 columsn ; Name,SyncName,Version,PPO,DOM from the BaseData table.. the problem is that after i do the inner join I get duplciate records..
i want to eliminate the duplicate records , can any one help me here
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. Now we have to guess and type, guess and type, etc. because of your bad manners.
CREATE TABLE Base_Env
(base_env_id CHAR(10) NOT NULL PRIMARY KEY,
Think about the name Base_Data; do you have lots of tables without data? Silly, unh?
CREATE TABLE Base_Data
(base_data_id CHAR(10) NOT NULL PRIMARY KEY,
Your Links table is wrong in concept and implementation. The term “link” refers to a pointer chain structure used in network databases and makes no sense in RDBMS. There is no generic, magic, universal “id” in RDBMS! People that do this are called “id-iots”
in SQL slang.
We can model a particular relationship in a table by referencing the keys in other tables. But we need to know if the relationship is 1:1, 1:m, or n:m. This is the membership of the relationship. Your narrative implies this:
CREATE TABLE Links
(base_env_id CHAR(10) NOT NULL UNIQUE
REFERENCES Base_Env (base_env_id),
base_data_id CHAR(10) NOT NULL
REFERENCES Base_Data (base_data_id));
>> The base_env_id is unique in the table where as base_data_id can be repeated I.e multiple rows of Base_Env Table can point [sic] to same Base_Data table row. <<
Again, RDBMS has no pointers! We have referenced an referencing tables. This is a fundamental concept.
That narrative you posted has no ON clauses! And the narrative is also wrong. There is no generic “name”, etc. What tables were used in your non-query? Replace the ?? in this skeleton:
SELECT ??.something_name, ??.sync_name, ??.something_version,
??.ppo, ??.dom
FROM Base_Env AS E, Links AS L, Base_Data AS D
WHERE ?????????;
>> I want to eliminate the duplicate records [sic], can any one help me here?<<
Where is the sample data? Where is the results? Please read a book on RDBMS so you can post correct SQL and try again.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL
Similar Messages
-
Need help with Blog, Wiki and Gallery
Hi Team,
Need help with Blog, Wiki and Gallery startup. I have newly started visiting forums and quite interested to contribute towards these areas also.
Please help.
Thanks,
Santosh Singh
Santosh SinghHello Santhosh,
Blog is for Microsoft employees only. However, you can contribute towards WIKI and GALLERY using the below links.
http://social.technet.microsoft.com/wiki/
http://gallery.technet.microsoft.com/ -
Need help with Airport Express and so on.
Ok so my main problem before getting into what I need help with here is that our MacBooks and now my iPhone 6 plus isn't staying online. Keep getting booted off and then I either have to select the network again or it will eventually go back on. If anyone has a solution or so please feel free to answer that as well. I'm running on Roadrunner with a Netgear 600 wireless router and a motorola modem. Both of which I'll leave the link to below for a better look.
My Main Question: So I'm looking at a new wireless router mainly and possibly a new modem. I know Apple products are trustworthy but how good is the Airport Express and other Airport products. Also what is the Maximum speed and Maximum data speed for the cheapest express station and if anyone knows the speeds of the other devices it would be greatly appreciated.DSL Router to Netgear 5-port Switch and I used the switch to connect to Airport Extreme, TV, Blue-Ray DVD player and DirecTV Receiver.
The AirPort Extreme base station (AEBS) is a router so it will do what you need.
You need to reconfigure your setup. Connect the WAN port of the AEBS to the DSL router. Then connect the Netgear switch to one of the LAN ports on the AEBS. The AEBS will properly share the connection. -
Need help with Page Layout and Background Scaling
hello, everyone.
I am in the process of designing a new website for myself,
and while I was researching nicely designed pages to use as
inspiration, I stumbled upon this site:
http://www.jeffsarmiento.com/
obviously, the design is very impressive, but it also
incorporates a lot of web mechanics that I have been trying to
figure out, so I will use this page as an example.
one thing I need help with is backgrounds. as you can see in
the posted website, the creator used a seamlessly tiled paper
texture to display the bulk of his content on. also make not of the
pattern that is located to the left of the paper texture. how do I
create seamless backgrounds like this that will scale to fit any
amount of content or any resolution? I can't imagine that the guy
that made that site created a new size background every time he
made an update, so there has to be an easier way.
the second thing that I am having trouble with is general
site layout. I have read that most sites used series of invisible
tables to organize there content, but when I open the source of
this page in dreamweaver, he was using something different. div
tags? should I be using these? who do I use them? are there any
general layout tips that someone could pass on to me? perhaps a
link to a good tutorial?
please help me. i am very confused.
thanks so much.IMO not a good site to emulate. To wit:
Top background image:
http://www.jeffsarmiento.com/images/bg-top.jpg;
745px
x 350px 137K
Main background image:
http://www.jeffsarmiento.com/images/bg-tile.jpg;
745px x 950px 130K
Total page size: 454K (Check here:
www.websiteoptimization.com)
Website usability experts routinely recommend a maximum page
size of ~80K
Check out the We We Scale @ www.FutureNowInc.com/wewe/ where
they suggest,
"You speak about yourself approximately 0,003 times as often
as you speak
about your customers. Might that have an impact on your
effectiveness?"
That is 100% consistent with the #1 Web Design mistake:
"Believing people
care about you and your web site." or to phrase more
expansively, "Our site
tries to tell you how wonderful we are as a company, but not
how we're going
to solve your problems."
www.sitepoint.com has some excellent books on making a
website actually
attractive and usable at the same time.
Walt
"beWILLdered_" <[email protected]> wrote in
message
news:[email protected]...
> hello, everyone.
> I am in the process of designing a new website for
myself, and while I was
> researching nicely designed pages to use as inspiration,
I stumbled upon
> this
> site:
>
http://www.jeffsarmiento.com/
> obviously, the design is very impressive, but it also
incorporates a lot
> of
> web mechanics that I have been trying to figure out, so
I will use this
> page as
> an example.
> one thing I need help with is backgrounds. as you can
see in the posted
> website, the creator used a seamlessly tiled paper
texture to display the
> bulk
> of his content on. also make not of the pattern that is
located to the
> left of
> the paper texture. how do I create seamless backgrounds
like this that
> will
> scale to fit any amount of content or any resolution? I
can't imagine that
> the
> guy that made that site created a new size background
every time he made
> an
> update, so there has to be an easier way.
> the second thing that I am having trouble with is
general site layout. I
> have
> read that most sites used series of invisible tables to
organize there
> content,
> but when I open the source of this page in dreamweaver,
he was using
> something
> different. div tags? should I be using these? who do I
use them? are there
> any
> general layout tips that someone could pass on to me?
perhaps a link to a
> good
> tutorial?
> please help me. i am very confused.
>
> thanks so much.
> -
Need help with saving data and keeping table history for one BP
Hi all
I need help with this one ,
Scenario:
When adding a new vendor on the system the vendor is suppose to have a tax clearance certificate and it has an expiry date, so after the certificate has expired a new one is submitted by the vendor.
So i need to know how to have SBO fullfil this requirement ?
Hope it's clear .
Thanks
BonganiHi
I don't have a problem with the query that I know I've got to write , the problem is saving the tax clearance certificate and along side it , its the expiry date.
I'm using South African localization.
Thanks -
Need help with show/hide and layers moving
I'm more of a designer, so I don't know code or CSS well at
all. I'm doing an online portfolio for a class and need help with
layers not staying in place in different browsers. The portfolio is
created with a table, but I wanted to use the show/hide function
for thumbnails of work. Are layers the only way you can use this
function? I read layers don't work well with tables, so how else
can I make it so when you mouse over a thumbnail, the larger image
appears in another cell?> I don't know code or CSS well at all.
That's unfortunate.
> layers not staying in place in different browsers.
Layers don't move. But the rest of your page does.
Before you get too wrapped up in layers, though, please read
this -
http://www.great-web-sights.com/g_layerlaws.asp
They are not good when be used as a primary layout method.
> I read layers don't work well with tables
They work fine with tables - but you have to understand both
tables and
layers to use them.
Why not show us your page, so we can see what you are
struggling with?
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"Bobbi67" <[email protected]> wrote in
message
news:ertd9h$h3m$[email protected]..
> I'm more of a designer, so I don't know code or CSS well
at all. I'm doing
> an
> online portfolio for a class and need help with layers
not staying in
> place in
> different browsers. The portfolio is created with a
table, but I wanted to
> use
> the show/hide function for thumbnails of work. Are
layers the only way you
> can
> use this function? I read layers don't work well with
tables, so how else
> can I
> make it so when you mouse over a thumbnail, the larger
image appears in
> another
> cell?
> -
Help with inner join PLEASE IGNORE
Hi I was doing a select with a subquery but I need that the where clause check to values so I couldn't get it so I decided to create a INNER JOIN
Before
insert into BPMTEMP (select * from ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1 where id_solicitud and accion not in (select (id_solicitud, accion) from ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1) and rownum <=200);but the problem with the inner join is that it doesn't accept me the external database source
insert into BPMTEMP (select ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1.*, ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1.*
from ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1
INNER JOIN ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1
ON [email protected]_solicitud = [email protected]_solicitud
ON [email protected] = [email protected]
AND rownum <=200); it shows an:
ORA-02084:
database name is missing a component
Cause: supplied database name cannot contain a leading '.', trailing '.' or '@', or two '.' or '@' in a row.
how can I solve this????
thanks for your help
Edited by: Diego Guillen on 29/12/2009 11:14 AMHi
Please remove the @dblink stuff in the column descrptions or use a table alias. This should help.
drop database link lokal;
create database link lokal
CONNECT TO whateveruserineed IDENTIFIED BY whateverthing
USING 'lokal11g';
select HR.COUNTRIES.* from HR.COUNTRIES@lokal;
select x.* from HR.COUNTRIES@lokal x;And as Dan Morgans says, pls. post you ? in the right forum next time :-))
Mette -
Help with Inner Join query in SQL
Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
My table structure is :
table_packages
packageID
package
packageDetails
etc
table_destinations
destinationID
destination
destinationDetails
etc
table_packagedestinations
packageID
destinationID
..so nothing that complicated.
So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
This is the PHP from the header, including my INNER JOIN query....
PHP Code:
<?php
$ParampackageID_WADApackages = "-1";
if (isset($_GET['packageID'])) {
$ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
$ParamSessionpackageID_WADApackages = "-1";
if (isset($_SESSION['WADA_Insert_packages'])) {
$ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
$ParampackageID2_WADApackages = "-1";
if (isset($_GET['packageID'])) {
$ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
mysql_select_db($database_connPackages, $connPackages);
$query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
$WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
$row_WADApackages = mysql_fetch_assoc($WADApackages);
$totalRows_WADApackages = mysql_num_rows($WADApackages);
$colname_educationalDestinations = "1";
if (isset($_GET['PackageID'])) {
$colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
mysql_select_db($database_connPackages, $connPackages);
$query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
$educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
$row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
$totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
?>
And where I'm trying to display the destinations themselves, I have :
<table>
<tr>
<td>Destinations :</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_educationalDestinations['destination']; ?></td>
</tr>
<?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
</table>
If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working.
Thanks.First off, you need to get the database tables so that there is a relationship between them.
In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
table_packages
packageID
package
packageDetails
destination
destinationDetails
etc
If there is a one to many relationship, then the following would be true
packages
packageID
package
packageDetails
etc
destinations
destinationID
packageID
destination
destinationDetails
etc
The above assumes that there are many destinations to one package with the relationship coloured orange.
Once you have the above correct you can apply your query as follows
SELECT *
FROM packages
INNER JOIN destinations
ON packages.packageID = destinations.packageID
WHERE packages.packageID = %s
ORDER BY destination ASC
The above query will show all packages with relevant destinations -
Need help with self join query
Hello,
I have table A with the following data
oid parent_oid
10 4
4 2
2 2
12 6
6 6
parent_oid is the parent of oid. I'd like a query that shows the final parent of the oid. The result should show the following
oid final parent
10 2
4 2
2 2
12 6
6 6
I'm using Oracle 10g. I'm familiar with self joins, but that alone will not do the job. Thanks!Hi,
arizona9952 wrote:
... I'm familiar with self joins, but that alone will not do the job.You're absolutely right!
A 2-way self join would work for rows have no parent, or rows that are directly connected to their final ancestor (such as oid=4), but not for anything farther away.
A 3-way self-join would work for one more level away from the final row, but no more. That would be enough for the small set of sample data that you posted, but it would not work if you added a new row with parent_id=10.
An N-way self-join would work for up to N+1 levels, but no more.
You need something that can go any number of levels, such as CONNECT BY:
SELECT CONNECT_BY_ROOT oid AS oid
, parent_oid AS final_parent
FROM a
WHERE CONNECT_BY_ISLEAF = 1
CONNECT BY oid = PRIOR parent_oid
AND oid != parent_oid
;Edited by: Frank Kulash on Feb 22, 2010 7:09 PM
Upon sober reflection, I think that a Top-Down query, like the one below, would be more efficient than a Bottom-Up query, like the one above:
SELECT oid
, CONNECT_BY_ROOT parent_oid AS final_parent
FROM a
START WITH parent_oid = oid
CONNECT BY parent_oid = PRIOR oid
AND oid != PRIOR oid
; -
Need Help with the Total and Grand Total
Hi All,
I have posted a question couple of days ago regarding the COUNT and AVERAGES, for a minute i thought i got the work around, but the problem still exists. I'm trying to find the average work done and average revenue generated. I have to do this by the location,
employee id , date and the number of hours. Below is a sample for february 2014. I have two averages for the work done AvgWorkDone=(sum of work done/count of workingdays in month), the second one is AverageWorkDone1... which i skewed by multiplying by 16 (since
there are 16 hours in my data per day) Please need help
Year Name
Calendar 2014
Month Of Year Name
Month 2
Row Labels
workdone
STG WORKDONE VW Count
AvgRev
AvgWorkdone
AvgWorkdone1
1
2433.333333
368
1.591304348
6.612318841
105.7971014
1368
2433.333333
368
1.591304348
6.612318841
105.7971014
10AM
0
23
0
0
0
11AM
23.33333333
23
0
1.014492754
16.23188406
12PM
91.66666667
23
0
3.985507246
63.76811594
1PM
58.33333333
23
0
2.536231884
40.57971014
2PM
41.66666667
23
0
1.811594203
28.98550725
3PM
161.6666667
23
0
7.028985507
112.4637681
4PM
176.6666667
23
0
7.68115942
122.8985507
5AM
0
23
25.46086957
0
0
5PM
191.6666667
23
0
8.333333333
133.3333333
6AM
0
23
0
0
0
6PM
450
23
0
19.56521739
313.0434783
7AM
0
23
0
0
0
7PM
618.3333333
23
0
26.88405797
430.1449275
8AM
0
23
0
0
0
8PM
620
23
0
26.95652174
431.3043478
9AM
0
23
0
0
0
Grand Total
2433.333333
368
1.591304348
6.612318841
105.7971014
If you see the above report the number of days are adding upto 368, this causes the Individual Averages to be fine but the GrandToatl of the Average is messed up. If i multiply by 16 the Individual Averages are messed up, but the GrandAverage is coming RIGHT.
Please need help where i can get both the individual and the grand averages right.
SVHi All,
Finally i found a solution. a) I have a time dim from the ware house and its joined to the fact table based on the dateid, since the fact table is getting only the data for the working days , the ware house time dim is showing only those days as count.
b) I created a new time dim in SSAS TIMEDIMSSAS
c) I joined the new TIMEDIMSSAS to the warehouse time dimension and the fact table and created new measure AvgWorkDone over time and Avg Rev over time.
I'm getting what i wanted. BUT here is a new problem , when i select multiple months the grand total (which should be Average is showing wrong average and i'm not sure why), can anyone please help ?
Row Labels
AvgRevenue
AvgWorkDone
1
$4.17
277.6801802
1368
$4.17
277.6801802
February 2014
$1.59
105.7971014
January 2014
$0.97
64.66666667
March 2014
$9.52
634.5512821
Grand Total
$4.17
277.6801802
The values were supposed to be (1.59+.97+9.52)/3=4.02 and NOT 4.17 for Revenue. Similarly for WorkDone (105.79+64.66+634.55)/3=268.33 and NOT 277.68
Please can some one suggest what is going wrong here?
Thanks
SV -
Need help with Boot Camp and Win 7
I have iMac 27" (iMac11,1) 2.8 GHz, quad core, 8MB of L3, 8GB of Memory, Boot ROM Version IM111.0034.B02 and SMC Version 1.54f36 and can't get this machine to run Windows 7 using Boot Camp. I have successfully loaded Win 7 but when it claims to be starting I only get a black screen after initial start up.
I have checked and rechecked my software updates and have read and reread the instructions, however, I can't update my Boot Camp to 3.1 (my machine says i'm running 3.0.4) and I need 3.1 but can't load 3.1 because it is an exe file that has to be loaded into Windows after I load Windows but can't open Windows because I can't load Boot Camp 3.1. That's my excuse anyway, so I'm missing something I just can't figure out what it is....this is where you come in!
Thanks.
MikeMike,
I'm not going to be much help with Boot Camp however I can direct you to the Boot Camp forum where there are more people that know how to troubleshoot it and Windoze 7. You can find it at:
https://discussions.apple.com/community/windows_software/boot_camp
Roger -
FCP Novice needs help with video quality and FCP 5!!
Hi,
I have a real problme that I cannot seem to fix. I think its because I am doing something really wrong!
I have a Sony HC42E MiniDV Camcorder which by default records video in full widescreen. I recorded several tapes this way and have now begun trying to edit them in FCP 5.04 (Tiger 10.4.6). Whenever I log and capture my clips they appear to be fuzzzy and unclear on the Mac monitor whilst being totally crisp and sharp on the camcorder viewfinder. I tried capturing using the DV PAL 48Khz Anamorphic Preset which keeps everything the right size (the final output needs to be true widescreen and not with black bars added) but the resulting video on screen is blurry and bitty. I then tried capturing using the DV PAL 720 x 576 normal preset and the video is a little clearer on the screen (for both presets I have chosen lower field dominance) but when I play back it plays back in widescreen on the mac canvas window but at 4:3 on the camera's viewfinder.
I then assumed that maybe this is just becuase the mac screen (CRT by the way) doesn't use fields. So I exported the sequence as a QT movie using DV PAL 16:9 and used quicktime (OS9 Classic - my compressor has never worked because of the dreaded "unable to connect to baackground process" problem which I've never managed to correct) to convert it to MPEG2. When I import this as an asset into DVD Studio pro 4 and set the track size to 16:9 it comes through at the right aspect ratio. However it looks blurry on screen. Thinking that this will be fine on a TV I burned the disc - inserted it into my DVD player (a good one!) and watched it on my new 32" widescreen TV (a good one!) and the picture qualitty is poor. Its so much blurrier and bittier than the original footage looks when played through the camcorder's viewfinder!
The final footaage looks like an old VHS recording that's a year or two old!
Does anyone know how I can capture my footage in FCP with the maximum quality, edit it without quality loss and the export it for DVD again without such significant quality loss whilst all the time keeping it at proper 16:9 widescreen?
Is there some presets I should be working to?
I'm tearing my hair out! Help!Hi Guys,
thanx for your replies.
here's the latest:
Brian, I followed your instructions and the DVD burned successfully. However the video quality of the dvd when viewed on my TV ('ve tried on all 3 of my tvs now) is still a lot poorer than the quicktime movie that was imported into DVDSP4. When I play the original QT Movie on my Mac CRT monitor it looks a little blurry and grainy because I guess its non interlaced however when viewed on an external Video monitor it looks great - very sharp.
When I view the burned DVD on my television the picture quality looks like the non interlaced version of the original QT Movie that appeared on my Mac CRT and not the sharp interlaced (lower field) version that appeared on my external video monitor.
Its almost like taking a sharp jpeg into Photoshop and applying a gaussian blur of about 0.3 followed by jepg compression compressing it down to 5% quality!
I'm totally mystified. Can the conversion to Mpeg2 be removing all interlacing so that you get the less sharp computer monitor look? I just want the video on my final DVDs to be as good as the original source footage! I appreciate that along the way there might be loss of some quality but surely not that much?
Does this make sense to you guys or am I still doing something very wrong?
Robert: I have tried setting all manner of drives including a fresh external firewire HD with nothing on it (clean out of the box) but it doesn't seem to help.
Brian: I tried the no network suggestion a few months back but I'm not sure if I got it right. At the moment I have broadband through an external speedtouch usb modem and am also connected (occasionally although not for the last 3 months) via a crossover cable to my PCs ethernet card. When I last tried the No Network solution I had immense trouble getting my internet to work again! Can you please help me by directing me to the best ay to do this while protecting my internet settings?
any more help guys would be greatfully appreciated. -
Need Help with complex query and computing values
I have an issue trying to combine data from several tables. I need help trying to compute the "Total Hours", "Max Pressure" ,"Average Pressure" while displaying the "Manufacturer",
"Part Type" , "Serial Number", "District", "Status","Truck Type",and "truck number" for a certain Part on all Trucks. I need to be able check and see if the serial number was on
a particular job and calculate the hours of that serial number if it was on that job and the jobdate falls between the install date and removal date. Ive tried but keep getting either
repeating rows, total hrs of the truck instead of the serial number. Ive considered doing a pivot to display it but have been having trouble putting it together.
table 1
(*records of parts*)
Contains serial number,truck number, part type, part number, install date, removal date, status
table 2
(*records of Jobs*)
contains Jobnumber, JobStartdate, Max pressure, average pressure, and Totalhrs
table 3
(records related to jobs and trucks)
contains jobnumber, district , and truck numbers
Table 4
(records of manufacturers and part numbers)
contains partnumber, manufacturer name, and truck type
I would like to get it to show like below
SerialNo PrtType
MFG TruckNo
TrkType TtlHrs
MaxPr AvgPr
Status
Dst
AB345 1200series
NGK 2G34
Boss X 400 10,000
9500 NonOp
NE
Thanks in advanceHope this helps
Note: (Date of Mar 1 2014 was just extended to a further date so the system would know that its still operating when calculating current hours)
Table 1
SerialNo TruckNo InstallDate RemovalDate Status PartNo PartType
BJ1002 F917 2013-09-17 2014-03-01 Oper L871235 BJ 3000 GL
CWS1002 F104 2012-11-21 2013-03-29 NonOper L76088-450 CWS 2000
CWS1003 F104 2013-04-24 2013-08-01 NonOper L76088-450 CWS 2000
CWS1005 F187 2012-11-21 2013-04-04 NonOper L76088-450 CWS 2000
CWS1006 F187 2013-04-24 2013-06-30 NonOper L76088-450 CWS 2000
CWS1007 F187 2013-06-30 2013-03-01 Oper L76088-450 CWS 2000
CWS1009 2F60 2013-05-05 2013-03-01 Oper L76088-450 CWS 2000
CWS1011 F809 2013-05-28 2013-08-28 NonOper L76088-400 CWS 2000
CWS1013 F990 2013-06-11 2013-10-29 NonOper L76088-450 CWS 2000
CWS1015 F783 2013-06-28 2013-03-01 Oper L76088-450 CWS 2000
Table 2
JobNumber Date District PrAvTreat PrMaxTr TotalHrs
553811287 2012-01-19 Fairmount 7337 8319 1.53
652110088 2012-08-20 San Antonio 6340 7075 0.47
652110090 2012-08-21 San Antonio 6134 7131 0.62
652110091 2012-08-22 San Antonio 6180 2950 0.58
652110092 2012-08-23 San Antonio 5959 6789 0.64
652110093 2012-08-23 San Antonio 6165 7466 0.62
Table 3
TruckNo District JobNumber
1F01 Odessa 10011012329
1F01 Odessa 10011012333
1F01 Odessa 10011014831
1F01 Odessa 10011014834
1F01 Odessa 10011012332
1F01 Odessa 10011012328
1F01 Odessa 10011014829
Table 4
PartNumber Manufacturer TruckType
L322020-2 Jimmy Dean Ford T
L322738-2 Lucas Ford T
L47869-1 Jimmy Dean Ford T
L76070-650 NGK Ford T
Sam Howard -
Hi there,
So, I've been browsing the SL and Mavericks forums for the last days but although I have fetched some useful tips and answers, still need some help. Let me put it diary-style so I can be more concise ;)
Here's my current system profile:
iMac 27" (aluminium back- if I'm no wrong, from around late 2009-mid 2010)
MacOS 10.6.1 Never updated.
3.06 Ghz Intel Core2 Duo
4Gb RAM
LaCie Big Disk via FireWire 800
Internet access via Ethernet port (cable)
And here's The Issues Log:
– Day one: First ever Kernel Panic. Restart. Nothing (apparently) wrong.
– 3 weeks elapsed: Second Kernel Panic. Same. iMac restarts fine. Apps fine. No missing files. No misbehaviour experiences.
– After a month or so: One morning, Skype decides on its own to stop launching. The night before, I chatted with one of my clients, fine as always, but at the next day, nothing. Computer is usually shut off for the night. And so it was that night. Updated Skype and also did all the guest account trick / repaired permissions / repair ACLs. Nothing worked. Overwrote the Skype app with a former functioning version I have in an MacOS 10.5 system. Didn't work. Now I have to chat on the MacOS 10.5 computer. No good.
– 15 days ago or so: After realising that I no longer have my HP1515n printer (it ran out of inks and thrashed it. It costs more to refill than to buy a new one), I deleted the printer from the printers list in the System Prefs Pane.
– Last week: Acrobat (CS4) won't launch a PDF file and freezes. Spinning beach ball. Force quit and try opening the PDF file again. Freezes again. And again. And again. With that file and every other PDF.
Photoshop CS5 fails to open or crashes when attempting to open any jpg or tiff file. InDesign and Illustrator CS5 are frozen and had to force quit both. MacOS 10.5
Restart the iMac thinking it is just a "common" bad day and hoping everything will be alright after the restart, but nope.
Not only the CS5 stops working; MSOffice stops working too. Spinning beach ball. Begin to suspect of the deletion of the printer, however, I also deleted the same printer in the above mentioned 10.5 system and I'm not experiencing anything strange. Reinstalled the HP drivers but nothing remarkable happens.
Then, try to uninstall CS5, CS4, Office, etc. Try to reinstall Acrobat CS4 and the CS5 apps. Reinstall Office. Nothing. Just Outlook works.
Since I had to desperately meet deadlines, convinced a colleague to come over to the studio and -I know, I know- allowed me to install a copy of CS6. It seems to work fine, except for Acrobat, which randomly freezes/hangs/works and Photoshop, which works fine unless you want to open a layered file containing text layers or if you want to type text on a normal file, because it freezes as soon as the Text Tool is pressed in the toolbar, of course, spinning beach ball again.
Well, Illustrator CS6 sometimes shows a strange black thin frame overlaid on the interface but goes away by switching to another workspace and then back to the current. InDesign CS6 seems to be fine and making PDFs as expected. However, as I said before, it is pure luck if Acrobat accepts to open the file or even if it launches. Spinning beach ball when freezing/hanging.
As a method for eliminating possible culprits, did a clean up of the Suitcase Fusion database, removed duplicate and a few (less than 10) corrupted fonts.
Removed completely MSOffice reinstalled and updated. Nothing. Now I neither have MSoffice running.
I am no rookie but I can't even imagine what can cause such amount of misbehaviour, (kernel panics have something to do? malware? lack of system updates? MacHD is damaged?) so I'm thinking of a few scenarios:
Backing up my projects and user folder –anything else to backup? (In fact I've already done that)– and:
1. Do a clean install. Not sure if it will be best to completely erase the whole drive or if a standard reinstallation will be enough.
2. Take the machine to a Genius Bar to see if there's anything that can be done without major OS messes.
3. Erase the drive and go through the Mavericks upgrading (SL to Ln to MLn to Mavcks), although not sure if this upgrade is worth yet.
4. Replace HD for a brand new one and either step 1 or 3.
5. As a complement, I'm thinking of adding more RAM.
Well. It is really the first time I don't know what to do. I have work to do and would not want to face a week away from my main computer and since most of the files are CS5-6 and hence, can't move to my wife's iMac...
Apologies if this post feels too long, but I will truly appreciate any kind of input and advice on one of more of the issues mentioned in this post.
And if it fits best in any other forum, please also let me know.
Cheers and thanks in advantage.You have to use the Base Station Menu on the Menu Bar at the very top of your screen.
Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
I am employed by HP -
I have the following table structure,
Table - 1_
ID | Information
1 | abcadskasasa
2 | asdasdasdasd
3 | saeqdfdvsfcsc
Table - 2_
ID | PID
1 | 12
1 | 13
2 | 14
1 | 15
1 | 16
2 | 12
Table - 3_
ID | PARID
1 | 12
2 | 14
1 | 15
Now I want to select for each ID in table 1, the count of number of PID from table 2 and count of number of PARID from table 3.
Desired output:_
ID | COUNT_PID | COUNT_PARID
1 | 4 | 2
2 | 2 | 1
3 | 0 | 0
Could anyone please help me out with this. I am trying to make use of outer joins, but as I work mostly on the front end so, not able to come up with a proper solution for the above.
Thanks in advance,
TejasHi, Tejas,
You might have been doing the outer join correctly.
There's another problem here: joining table_1 to two other tables with which it has a one-to-many relationship.
If you were joining table_1 to just one other table, you could say:
SELECT t1.id
, COUNT (t2.pid) AS count_pid
FROM table_1 t1
LEFT OUTER JOIN table_2 t2 ON t1.id = t2.id
GROUP BY t1.id
ORDER BY t1.id;You could have done the exact same thing with table_3 instead of table_2.
But you can't do the same thing with both table_2 and table_3 at the same time: that would be like cross-joining table_2 and table_3. Instead of showing id=1 having count_pid=4 and count_parid=2, you would get cout_pid=8 and count_parid=8 (since 8 = 4 * 2).
You can do a separate GROUP BY on (at least) one of the tables.
This gets the right results. In the main query, there is only one one-to-many relationship.
WITH t3_summary AS
SELECT id
, COUNT (parid) AS count_parid
FROM table_3
GROUP BY id
SELECT t1.id
, COUNT (t2.pid) AS count_pid
, MAX (t3.count_parid) AS count_parid
FROM table_1 t1
LEFT OUTER JOIN table_2 t2 ON t1.id = t2.id
LEFT OUTER JOIN t3_summary t3 ON t1.id = t3.id
GROUP BY t1.id
ORDER BY t1.id;
Maybe you are looking for
-
Pick Release single line in a sales order
Hi All, I want to pick release a single line from a sales order i.e if i have a sales order which has 3 lines and i want to pick release first line using Release Sales Order form of OM R12. I am giving the delivery detail id in Release Sales Order fo
-
I use iCloud. I have an iPhone, Apple laptop, and I recently bought an iPad. I can view the pictures I take on my cell phone on my iPad. But what about all the pictures I took on my phone before I bought my iPad? How do I view those on my iPad?
-
Unable to Restore BB Software after OS Upgrade
Hi. I am unable to restore several programs (PWKeeper, BBM, BBTraffic, Memo, Tasks, Maps) after a wipe and OS upgrade. I backed up the phone prior to the wipe but did not turn off wireless sync. Learning now that I should have. I have deleted deskt
-
Hi Guys, I have been searching this forum if some one implemented a scenario something like mine here. In my project I am creating users to access my application and storing in a table and at the same time the user information must be sent to a diffe
-
The Limits of Dynamic Link...
I'm working on an all green screen video. I did my cut in PPRo CS3, then opened the project in AE CS3. I used keylight to do all the keying, then used Dynamic Link to bring the project back into PPro. Upon trying to render it, it stopped and gave the