Can't get query to work. table alias in subquery in FROM clause
How can I rearrange this query to work?
SELECT
TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
(SELECT COUNT(*) FROM
(SELECT DISTINCT a.non_asp, a.start_time, a.end_time
FROM appointments a
WHERE a.start_time >= dt.date_time AND a.start_time < dt.date_time + 1
) num_overlap
FROM
table(times_pkg.between_times(TO_DATE('2010-05-30'),
TO_DATE('2010-07-03'), 60*24, 'Y')) dtbetween_times is a table function that returns times at given intervals.
I am trying to get a count of distinct (non_asp, start_time, end_time) sets that fall on each day.
However, it doesn't recognize dt.date_time in the FROM clause.
Hi,
A sub-query can be correlated only to its immediate parent. You're trying the correlate the SELECT DISTINCT sub-query to its grandparent.
You can re-write the sub-query as a join, like this:
SELECT TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
a.num_overlap
FROM table ( times_pkg.between_times ( TO_DATE('2010-05-30'),
TO_DATE('2010-07-03'),
60*24,
'Y'
) dt
JOIN (
SELECT start_time,
end_time,
COUNT (DISTINCT non_asp) AS num_overlap
FROM appointments
) a ON a.start_time >= dt.date_time
AND a.start_time < dt.date_time + 1
;You could also eliminate the extra level between the SELECT DISTINCT sub-query and the main query by using SELECT (DISTINCT ...).
Similar Messages
-
Making a join seems simple but I can't get it to work
Hi All,
I have 2 tables LUGallery and LUSubGallery, the tables are related by the GalleyID field
LUGallery
Gallery ID
ClientID
GalleryName
5
50
Australia
8
50
Weddings
12
33
Portraits
4
33
Landscapes
LUSubGallery
SubGalleryID
GalleryID
GalleryName
67
5
NSW
68
5
QLD
69
8
Reception
70
8
Location
87
8
Ceromony
97
4
Rain Forest
What I am try to do seems simple but I can't get it to work the way I want it.
I am trying to write a query to display Galleries from the LUGallery tbl that have a Sub Gallery attached to them (ie. It's GalleryID appears in the LUSubGallery tbl)
So the query for the above example would list Australia, Weddings & Landscapes
I have tried to write code both with inner joins and nested queries but just can't get it right,
Any help would be greatly appreciated.
Thanks in advance
KrisI just want to
display the GalleryNames from the LUGallery tbl once
Then you probably do not want include all the extra columns from the LUSubGallery table.
It returns all of the records from both tables that Have
the same GalleryID
That is the way this type of JOIN works. It will return one record for each matched GalleryID. If you only want to display the unique gallery names you can either:
1) Use an EXISTS clause. It will return the distinct records from the main gallery table IF a matching record exists in the LUSubGallery table
--- Not tested ---
SELECT LUGallery.GalleryID,
LUGallery.GalleryName
FROM LUGallery
WHERE EXISTS (
SELECT *
FROM LUSubGallery
WHERE LUGallery.GalleryID = LUSubGallery.GalleryID
http://www.techonthenet.com/sql/exists.php
... OR ....
2) Use the DISTINCT operator to return only the unique combinations of the selected columns. Note: DISTINCT considers all columns in the SELECT list . So if you only want unique galleries, do not include the LUSubGallery columns in the SELECT list.
http://www.w3schools.com/SQl/sql_distinct.asp
Message was edited by: -==cfSearching==- -
Hello
I added content to a document in Pages on my Mac last night, which was saved to icloud and this morning the additions were gone. Can I get my precious work back? ThanksJust thought I'd add my solution, I decided to go with WebDAV and I think it actually works better than the iTunes way, the steps are pretty much the same but avoiding the iTunes interface just makes things easier and faster.
I followed this guide but it does have a small mistake in the httpd-dav.conf file, on line 2, where it's WebServer/WebDAV">, it should be <Directory "/Library/WebServer/WebDAV">.
The tricky part is setting permissions which if wrong will give you errors when connecting with the iPad, I opted to set all to Read&Write since my home network has a hardware firewall. Another convenience was to add an alias to the webdav share on the Desktop.
I'm still expecting the call from Apple but even if they fix the iTunes I'm sticking with WebDAV, atleast until I see what's new with iOS5 and iCloud this fall which should bring true sync for documents (I'm hoping that they will offer encryption with my own keys, if not, then I'll probably keep using WebDAV). -
Can't get VPN to work on RV220W
I am a home office user who bought a RV220W router for the speed advertised on smallnetbuilder. I am trying to set up the VPN but can't get it to work with the Quick VPN client. I am using dyndns to manage the dynamic IP and have entered that into the setup noted below. I can access the router remotely (remote administration) when enabled using the dyndns address so I know that is working.
IKE Policy Table
General
Policy Name: krafty001vpn
Direction / Type Responder
Exchange Mode: Aggresive
Enable XAUTH Client: None
Local Identification
Identifier Type: FQDN
FQDN: krafty001.dyndns.org
Peer IKE Identification
Identifier Type: Remote Wan IP
FQDN: krafty001.dyndns.org
IKE SA Parameters
Encryption Algorithm: 3DES
Authentication Algorithm: SHA-1
Authentication Method: Pre-Shared Key
Pre-Shared Key: xxxxxxxxx
Diffie-Hellman (DH) Group: Group 2 (1024bit )
SA-Lifetime: 28800 Seconds
VPN Policy Table
Add / Edit VPN Policy Configuration
Policy Name:
krafty001vpn
Policy Type:
Auto Policy
Remote Endpoint:
FQDN
krafty001.dyndns.org
NETBIOS:
Enable
Local Traffic Selection
Local IP:
ANY
Start Address:
End Address:
Subnet Mask:
Remote Traffic Selection
Remote IP:
ANY
Start Address:
End Address:
Subnet Mask:
Split DNS
Split DNS:
Enable
Domain Name Server 1:
Domain Name Server 2:
(Optional)
Domain Name 1:
Domain Name 2:
(Optional)
Manual Policy Parameters
SPI-Incoming:
SPI-Outgoing:
Encryption Algorithm:
3DES None DES AES-128 AES-192 AES-256 AES-CCM AES-GCM
Key-In:
Key-Out:
Integrity Algorithm:
SHA-1 SHA2-256 SHA2-384 SHA2-512 MD5
Key-In:
Key-Out:
Auto Policy Parameters
SA-Lifetime:
3600
Seconds KBytes
Encryption Algorithm:
3DES None DES AES-128 AES-192 AES-256 AES-CCM AES-GCM
Integrity Algorithm:
SHA-1 SHA2-256 SHA2-384 SHA2-512 MD5
PFS Key Group:
Enable
DH-Group 1 (768 bit) DH-Group 2 (1024 bit) DH-Group 5 (1536 bit)
Select IKE Policy:
krafty001vpn
Quick VPN Setip
User Profile: homevpn
User Name krafty001vpn
Password: xxxxx
Server Address: krafty001.dyndns.org
Port for QuickVPN: Auto
Any help in identifying what setup component I have configured incorrectly would be appreciated
ThanksI am not sure this will help but make sure the following is set correctly:
Currently VPN is somewhat broken on all versions of firmware of the RV220W including beta where VPN will ONLY negotiate on 443. If you are port forwarding 443 to a server or something else it will fail. You must allow the VPN to authenticate on 443. The router SHOULD be able to connect on 60443 as indicated on the QUICKVPN software however it doesn't this has been confirmed by a CISCO engineeer I have been speaking with regarding my VPN woes. Currently there is NO ETA on this fix.
But since you didn't mention if your 443 ports were being routed elsewhere I figured i would lay out that information here incase you where. Also I strongly recommend contacting Cisco Support for the beta firmware it makes the RV220W much better.
Also the reason for the update to the beta firmware it resolves the hair pinning problem which could also lead to VPN issues. -
Can't get Export to work in iPhoto 6.0
I can't get Export to work. I haven't been a big iPhoto user but just upgraded from ver. 2.0.1 to 6.0 four days ago. Never used export before; however, going through the '06 tutorial I have tried and failed several times (but dragging to the desktop works). I select a photo and File-->Export and the "Export Photos" dialog comes up. I hit the "File Export button at the top" per iPhoto Help. Nothing happens; the File Export pane remains blank. Hitting "Export" doesn't work either. Only the Cancel button works. I have a relatively small library: about 200 from before the upgrade and 100 imported using the new alias feature. Would appreciate any advice.
PowerMac G4 QuickSilver Mac OS X (10.4.4) 1.12 GB RAMHi Walt,
did you use an iPhoto plugin before? Maybe you have an outdated flickr plugin that needs to be updated or disabled.
Do a "get info" on iPhoto.app and see if you have that installed.
The plugins are listed at the bottom of the "get info" panel -
In Numbers 09 there was 'rearrange' which worked perfectly. New Numbers 13 has Sort by column but I can't get it to work. is there a bug?
Numbers '09 has a Reorganize panel and the top section of that panel is for sorting. Numbers 3 also has the ability to sort and it works. However, Numbers '09 and Numbers 3 sort differently.
In Numbers '09, if you had a formula such as =Table 1::A1 and if a sort of Table 1 moved cell A1 to A20, the formula would change to =Table 1::A20. In Numbers 3, the formula would stay =Table1::A1. -
Have entrourage and want to use Mail. Can't get it to work.
I had a macbook and purchased the Microsoft office for Mac which included Entrourage.
I have now purchased a new macbook Pro and want to begin to use Mail rather than Entrourage.
I have Entrourage on my new computer but i can't get it to transfer my information to the the Mail program
I am on Charter.net at my office and sbcglobal.net at home.
How can i get this to work. I can receive on Mail, but i can't send.check your outgoing port settings and make sure it's using a specific port and not the default port, also you might want to check to see if it is using SSL, TLS or any other encryption. Verify the setting from your old machine setup.
-
got my password wrong twice and my mini is disable. I connected to iTunes, but can't get it to work. Can some one guide my through?
If it's showing the red disabled screen due to incorrect passcodes then you may need to put the iPad into recovery mode : http://support.apple.com/kb/ht1808 - you should then be able to reset the iPad via your computer's iTunes and restore/resync your content to it
-
HT1151 i have a new apple external dvd drive, and i can't get it to work with my iMac?
I have a new apple dvd drive, I was told it will work with my imac, but when i plug it in ...nothing... iv been for update... still nothing. How can i get it to work???
If it is this drive, note that it is for MBA's and Mini's only:
http://store.apple.com/us/product/MC684ZM/A
Ciao. -
Is there a way to reset my messages account, I can't get iMessage to work on IPad nor Mac osx. Help please this is really frustrating.
Hi,
Is there an iPhone involved ?
If not, what happens if you remove the Apple ID on the iPad and then set it in Airplane Mode (allow a couple of minutes at this point) followed by re-adding the Apple ID ?
What, if any error messages are appearing on the Mac when you try to launch the App or Login to the iMessages server ?
Is the Apple ID linked to an iCloud account ?
In Messages 7 (Mountain Lion) this did not seem to be important but it seems it is in Mavericks/Messages 8
9:14 pm Friday; April 11, 2014
iMac 2.5Ghz i5 2011 (Mavericks 10.9)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad -
I bought an IR receiver and an Apple Remote, and I can't get it to work. What am I doing wrong? The receiver is a Lenovo eHome OVU430006/01 USB IR Receiver.
Hello,
You would need to pair the Apple Remote with the receiver. So I would use the generic Mac/PC receiver and follow these instructions:
http://support.apple.com/kb/HT1619
If that doesn't work then check in System Profiler to see if the IR receiver has been recognized by the PowerBook's hardware. You may require the install of drivers for this device to be recognized.
Best of luck -
I have a go daddy email account and I can't get it to work on my iPad
I have a go daddy email account and I can't get it to work on my iPad
Try turning the email account off and then turn it on again. Settings>Mail, Contacts, Calendars>select your gmail account>Off. Go to the mail app and then come back to the account in the settings and turn it on again.
If you can't find any other way for the iPad to accept the password, delete the email account and then add it back onto the iPad. -
I have a Mac Mini and I can't get it to work with my Ricoh Aficio MP 161. Any ideas?
I have a Mac Mini and I can't get it to work with my Ricoh Aficio MP 161. Any ideas?
The latest Apple driver support begins with the MP 171.
Here is Ricoh's official driver download page specifically for the Afico MP 161. Note that new drivers for this device were released on Aug 2, and include Lion and Mountain Lion.
Hopefully, this will solve your device issues. -
Iphone 5 went black. Tried pushing on/off and circle at the same time. Worked yesterday and then did it again today. Can't get it to work.
You need to hold those button longer until you see the apple logo, then release, then wait for the phone to boot back up.
-
I just bought a new computer and had files transferred along with itunes to the new computer. I can't get it to work. It doesn't recognize the extensions for itunes. I also tried downloading Quicktime and couldn't get it to download.
iOS: Device not recognized in iTunes for Windows
I would start with:
Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
Maybe you are looking for
-
How to find out the table name
hi, how to find out the table name in which the data from a particular structure in a particular screen is saved, please tell me the procedure to find out the table name for saving the structure data that is inputted at runtime. Thanks, chinnu
-
Passing parameter in report for order by clause
how can we pass the name of the column on which we want the order by clause to sort as a parameter through parameter from in a report??
-
N85 video light problem?
hi all yesterday i traded my se w902 for a n85 and im really happy i did now before i used the phone i reinstalled fw v 11 today i wanted to take a video in a room with video light on in the settings when i press record it only flashes for 1 sec and
-
Doubt regarding User Name Policy
Hi, I have a requirement where I have to generate User Login based on First Name,Last Name and Employee Number(Employee Number generated in pre-process event handler). We have trusted recon in place. So. I opted for User Name Policy. I have written c
-
hi experts i have some doubts please clarify my doubts what are the extra process types in sap bi.ple tell me the answer. regards polu