Help with Query String Url
Hello All. I am in need of assistance in creating a query link for a sharepoint 2013 list. I would like to create a link that will query a column other than the Item ID: http://somesite.aspx?QuerySearch={ItemId}.
Is there a way to accomplish this, let's say
http://somesite.aspx?QuerySearch={Title}?
Hi,
According to your post, my understanding is that you wanted to creat a query link for a SharePoint 2013 list.
You can use the URL as below, it return the item which Title is equal to Test.
https://sitename/Lists/external%20test/AllItems.aspx?FilterField1=Title&FilterValue1=Test
In addition, you can use Query String Filter Web Part.
More information:
http://technet.microsoft.com/en-us/library/cc751316.aspx
http://www.wonderlaura.com/Lists/Posts/Post.aspx?ID=69
Best Regards,
Linda Li
Linda Li
TechNet Community Support
Similar Messages
-
Having problems creating PDF from website with query-string URLs
I have a website that I would like to create a PDF from. I am using the Create -> PDF from Web Page..., selecting the site's home page, and capturing 2 levels, with "stay on same path" and "stay on same server" checked in order to limit the scope of the crawl.
Where the pages are at example.com/foo/ and example.com/foo/bar/, this works fine. However, where the pages are at example.com/foo/ and example.com/foo/?p=1, the page represented by the query string URL is not converted to the PDF.
This is a problem, given that the site I want to archive as a PDF uses query strings for most of its pages.
I have been able to individually convert a single query-string-based page into a PDF using this method, but doing this for every page on the site would be almost impossible given the sheer number of pages on the site.
Is this a known issue? Is there a workaround other than separately capturing each page (which would be prohibitive effort)?
I have tried this in both Acrobat Pro X and Acrobat Pro 9 for Mac, with the same results.Remember, Acrobat is a 32-bit application and as such cannot access all that 'extra' stuff.
Be well... -
QSUF (Query string url filter) and SQL Server reporting services report viewer parameters
Hi,
this is my issue:
I have a SQL Server reporting services web part on a page with a report with 1 parameter, lets say it's a client list
Then i have a QSUF that will be used to filter the clients list through the URL
However, once i connect the filter and the report viewer web part, the parameter goes away and is no longer accessible
I'd like to somehow keep the parameter visible, in case there is no parameter sent through the URL, i would like the user to be able to choose a client from the parameter drop down list
I saw that there is a "send empty if no values are passed" option, but i can't seem to get this working properly and i don't know if this option will make the parameter visible again
Any help would be appreciated
Thanks.Hi,
According to your post, my understanding is that the query string url filter web part not worked well with SQL server reproting services web part.
Did you use the Wiki page layout in your environment?
You can change the page to a web part page, then check whether it work.
There is a similar thread for your reference.
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/4d7584e3-8e1a-48bf-9346-32f8cb480dd1/query-string-url-filter-web-part?forum=sharepointgeneralprevious
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support -
SharePoint 2013 List View with query string filter stops working after editing view from browser
I have created one list definition in which I have added one list view which will filter data from query string paramater
So when I am creating list from my list definition, view with query string filter is working fine.
But when I am modifying view from UI(I am not changing any thing , just opening "Modify View" page and then click on "Save" button), view gets stop working means it's not filtering data based on query string
Any suggestion what I am missing?
Below is my list view schema
<View BaseViewID="11" Type="HTML" TabularView="FALSE" WebPartZoneID="Main" DisplayName="$Resources:OIPLBScoreCard,viewFilterTasksByTarget;" MobileView="True" MobileDefaultView="False" Url="FilteredTasks.aspx" SetupPath="pages\viewpage.aspx" DefaultView="FALSE" ImageUrl="/_layouts/15/images/issuelst.png?rev=23">
<Toolbar Type="Standard" />
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
<ParameterBinding Name="TargetId" Location="QueryString(TargetId)" />
</ParameterBindings>
<JSLink>hierarchytaskslist.js</JSLink>
<XslLink Default="TRUE">main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>
<RowLimit Paged="TRUE">100</RowLimit>
<ViewFields>
<FieldRef Name="Body"></FieldRef>
<FieldRef Name="Title"></FieldRef>
<FieldRef Name="StartDate"></FieldRef>
<FieldRef Name="DueDate"></FieldRef>
</ViewFields>
<ViewData>
<FieldRef Name="PercentComplete" Type="StrikeThroughPercentComplete"></FieldRef>
<FieldRef Name="DueDate" Type="TimelineDueDate"></FieldRef>
</ViewData>
<Query>
<Where>
<Eq>
<FieldRef Name="oipscTargetLookup" LookupId="TRUE"/>
<Value Type="Lookup">{TargetId}</Value>
</Eq>
</Where>
</Query>
</View>
I have one lookup field from "Target List" in my source list and I want to filter data based on that lookup field.Hi JayJT,
The Miscellaneous is located in the contact list that you used for the connection.
So , you need to edit the page, then edit the contact list that you used, in the web part properties of the contact list, you will find Miscellaneous, then expand it and select ‘Server Render’ .
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
File uri with query string can't be propagated by desktop.browse()
I have been trying to show some help pages using the following command:
java.awt.Desktop.getDesktop().browse( helpURI);
while the helpURI.toString() prints out the following:
file:///C:/Share/Code/phoenix/Install/REDIST/Help_Files/en/wwhelp/wwhimpl/js/html/wwhelp.htm?context=BD&href=Chapter%202%20-%20Configuration.1.14.html
But when the getDesktop().browse() API is executed it will only propagate the uri-path and not the query string.
So the browser shows the following url as a result of the browse() call:
C:\Share\Code\phoenix\Install\REDIST\Help_Files\en\wwhelp\wwhimpl\js\html\wwhelp.htm
But if I manually copy the string "file:///C:/Share/Code/phoenix/Install/REDIST/Help_Files/en/wwhelp/wwhimpl/js/html/wwhelp.htm?context=BD&href=Chapter%202%20-%20Configuration.1.14.html" to the internet explorer it works fine.
So can somebody give me any guidance on how I can propagate the file uri with query string through the browse() API or is there a better API for that?
Sibon.The "cmd /S /C" suggestion didn't seem to work. I don't think the problem is in java but how the command line parameter needs to be added from msdos shell to "iexplore.exe"
When from the command line I enter the following command:
iexplore.exe file:///C:/Share/Code/phoenix/Install/REDIST/Help_Files/en/wwhelp/wwhimpl/js/html/wwhelp.htm?context=BD&href=Chapter%202%20-%20Configuration.1.14.html
I get the same result as invoking from java Desktop API --- it truncates everything from question mark. I tried palying around with double quotes, single quotes, escaping and nothing seem to work.
Any ideas? -
Hi,
I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
http://server/pages/Default.aspx?Title=Arup&Title=Ratan
But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
I have followed the
http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
Please suggest me.
Thanks | Arup
THanks! Arup R(MCTS)
SucCeSS DoEs NOT MatTer.Hi DH, sorry for not being clear.
It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
(or a Performance Point Dashboard etc.) and you insert it into your page and add
a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
with multiple values for one parameter. If you have any more questions let me know. See you, Ingo -
Sling mapping issue with Query String
For a button component, URL behaves differently with query string. Please let me know the sling mapping example for query string.
Button component behavior across env:-
Working Scenario:-
- In Author edit mode, URL pointing to "/content/<websitelink>"
- In Author preview mode shows URL "<host>:<port>/content/<websitelink>.html"
- In Publisher mode shows URL, "<host>:<port>/<websitelink>", we do not want "/content" before website link so it is fine.
Failure Scenario with query string:-
- In Author edit mode URL pointing to "/content/<websitelink>?username=han"
- In Author preview mode with URL "<host>:<port>/content/<websitelink>?username=han"
- In Publisher mode, <host>:<port>/content/<websitelink>?username=han - Here we see the content, which is not acceptable in our scenario.
Please let me know the mapping changes when we have a URL with query string.1) I assume you configure as per the rules mentioned in http://sling.apache.org/site/mappings-for-resource-resolution.html --> 'Mapping Entry Specification' under /etc/map. Based on the configuration in /etc/map and the website that we publish, it translates and shows all the applicable combination in the Felix console http://<host>:<port>/system/console/jcrresolver.
2) How does Adobe CQ 5.4 resolve the right mapping, if we have multiple map folder like below in /etc directory with the same website with different rules.
etc/map --> http --> <website> with property sling:match, sling:internalRedirect
etc/map.publish --> http --> <website> with property sling:match, sling:internalRedirect
etc/map.publish-stag --> http --> <website> with property sling:match, sling:internalRedirect
Kindly clarify. -
How do i pass a url with query string using the jsp:forward tag
This snippet of code gives a 403 error
<jsp:forward page="testpage.jsp?test=1" />
How do i rectify it?Well better way to go about for the job is to use
setAttribute("name","value");method in the first page
and then in next page use method
String s=getAttribute("name");to retreive the value.
Url rewritting or using Query String has some disadvantages ,which are handled by above mentioned approach.
Ashish -
FLVPlayback source with query strings (parameters) doesn't load
Flash version: CS4
AS version: AS3
I'm currently trying to use the FLVPlayback component and pass a source FLV that's living on a cloudfront webserver. The problem is that the cloudfront requires authentication in the form of query strings in the source FLV. For example:
import fl.video.*;
var mainMovie:FLVPlayback = new FLVPlayback();
mainMovie.source = "http://www.somedomainname.com/firmware.flv?dummyquery=22";
trace(addChild(mainMovie));
As soon as I take away the "dummyquery", it works fine. When I add a query string, it breaks (nothing loads).
Here is the error output I get:
[object FLVPlayback]
VideoError: 1005: Invalid xml: URL: "http://www.somedomainname.com/firmware.flv?dummyquery=22&FLVPlaybackVersion=2.1" No root node found; if url is for an flv it must have .flv extension and take no parameters
at fl.video::SMILManager/http://www.adobe.com/2007/flash/flvplayback/internal::xmlLoadEventHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
It adds on "&FLVPlaybackVersion=2.1" to the end.
I saw a different article that said I should add a dummy variable at the end like "&dummy=.flv" because I was told that Flash is basically looking for an .flv extension at the end and you can trick it, but it doesn't work because they add on additional code.
Does anyone know how to work around this?Hey supervu,
I know you already found a workaround to make this work, just figured I'd post an alternative to editing the FLVPlayback compoent. I also am retrieving an FLV file via a .Net ASHX file. To keep both worlds happy, I used a URLRewriter module to translate for me... this one translates what I am using for the FLVPlayback component source:
http://domain.com/flv/22.flv to be resolved as http://domain.com/API/resource.ashx?ID=22
There is of course no flv folder in the root of my application...
Here is my very simple URLRewriter class in vb.net:
Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Public Class URLRewriter
Implements IHttpModule
Public Sub Init(ByVal inst As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
AddHandler inst.BeginRequest, AddressOf Me.OnBeginRequest
End Sub
Public Sub OnBeginRequest(ByVal app As Object, ByVal e As EventArgs)
Dim inst As HttpApplication = CType(app, HttpApplication)
Dim req_path As String = inst.Context.Request.Path
Dim trans_path As String = ""
Dim search As String = "/flv/"
Dim pos As Integer = req_path.IndexOf("/flv/")
If pos > -1 Then
Dim key as string = req_path.Substring(pos + search.Length, (req_path.LastIndexOf(".flv") - (pos + search.Length)))
HttpContext.Current.Response.Redirect("~/API/resource.ashx?ID=" & key )
End If
End Sub
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
End Sub
End Class
and make sure you add this to your web.config.. this will cause URLRewriter to intercept all HTTP requests, and redirect as needed.
<system.web>
<httpModules>
<add name="URLRewriter" type="[Namespace].URLRewriter"/>
</httpModules>
</system.web>
Hope this helps someone. -
Help with query calculations (recursive)
Hi All,
I want some help with a query using a base rate and the result use in the next calculation year.
Here an example:
create table rate_type(
rate_type_id number,
rate_desc nvarchar2(50),
rate_base_year number
insert into rate_type(rate_type_id, rate_desc, rate_base_year) values (1, 'Desc1', 4.6590);
insert into rate_type(rate_type_id, rate_desc, rate_base_year) values (2, 'Desc2', 4.6590);
create table rates (
rate_type_id number
rate_year number,
rate_value number
insert into rates(rate_type_id, rate_year, rate_value) values (1, 2012, 1.2);
insert into rates(rate_type_id, rate_year, rate_value) values (1, 2013, 1.3);
insert into rates(rate_type_id, rate_year, rate_value) values (1, 2014, 1.4);
insert into rates(rate_type_id, rate_year, rate_value) values (2, 2012, 1.2);
insert into rates(rate_type_id, rate_year, rate_value) values (2, 2013, 1.3);
insert into rates(rate_type_id, rate_year, rate_value) values (2, 2014, 1.4);The calculation for the first year should be the base rate of the rate type. The next year should use the result of the previous year and so on.
The result of my sample data is:
2012 = 4.659 + 1.2 + 4.659 * (1.2 * 0.01) = 5.9149
2013 = 5.9149 + 1.3 + 5.9149 * (1.3 * 0.01) = 7.1859
2014 = 7.1859 + 1.4 + 7.1859 * (1.4 * 0.01) = 8.4721Query result:
NAME 2012 2013 2014
Desc1 5.9149 7.1859 8.4721
Desc2 XXXX XXX XXXX
How can I do this in one select statement? Any ideas?
Thanks!Assuming you are on 11.2:
with t as (
select a.rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
count(*) over(partition by a.rate_type_id) cnt,
row_number() over(partition by a.rate_type_id order by rate_year) rn
from rate_type a,
rates b
where a.rate_type_id = b.rate_type_id
r(
rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
result
) as (
select rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
rate_base_year + rate_value + rate_base_year * rate_value * 0.01 result
from t
where rn = 1
union all
select t.rate_type_id,
t.rate_desc,
t.rate_year,
t.rate_base_year,
t.rate_value,
t.cnt,
t.rn,
r.result + t.rate_value + r.result * t.rate_value * 0.01 result
from r,
t
where t.rate_type_id = r.rate_type_id
and t.rn = r.rn + 1
select *
from (
select rate_desc name,
rate_year,
result
from r
where rn <= cnt
pivot (sum(result) for rate_year in (2012,2013,2014))
order by name
NAME 2012 2013 2014
Desc1 5.914908 7.2918018 8.79388703
Desc2 5.914908 7.2918018 8.79388703
SQL> Obviously pivoting assumes you know rate_year values upfront. If not, then without pivoting:
with t as (
select a.rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
count(*) over(partition by a.rate_type_id) cnt,
row_number() over(partition by a.rate_type_id order by rate_year) rn
from rate_type a,
rates b
where a.rate_type_id = b.rate_type_id
r(
rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
result
) as (
select rate_type_id,
rate_desc,
rate_year,
rate_base_year,
rate_value,
cnt,
rn,
rate_base_year + rate_value + rate_base_year * rate_value * 0.01 result
from t
where rn = 1
union all
select t.rate_type_id,
t.rate_desc,
t.rate_year,
t.rate_base_year,
t.rate_value,
t.cnt,
t.rn,
r.result + t.rate_value + r.result * t.rate_value * 0.01 result
from r,
t
where t.rate_type_id = r.rate_type_id
and t.rn = r.rn + 1
select rate_desc name,
rate_year,
result
from r
where rn <= cnt
order by name,
rate_year
NAME RATE_YEAR RESULT
Desc1 2012 5.914908
Desc1 2013 7.2918018
Desc1 2014 8.79388703
Desc2 2012 5.914908
Desc2 2013 7.2918018
Desc2 2014 8.79388703
6 rows selected.
SQL> SY. -
Need help with contacting HTTPS URL
Hi,
I am new bie to Java Security. I do not know where to start off with. Here is the requirement.
I need to contact an HTTPS URL and this URL gives me output which is encypted data.
I have to save this ecnrypted data into a file and I have the KEY to decrypt the data.
I have tried several ways (all listed below) to get it working. But I am not successful. I get
"javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found"
Can you guys give me some insight on how to proceed?
Thanks
Mathew
import java.util.*;
import java.text.*;
import java.net.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.Permission;
import javax.net.ssl.HttpsURLConnection;
import java.security.*;
import java.security.cert.*;
import javax.net.ssl.*;
import java.io.*;
public class temp
protected BufferedReader messageResponseReader;
private static final String CERTIFICATE_TYPE = "SunX509";
private static final String KEYSTORE_TYPE = "JKS";
private static final String SSL_PROTOCOL = "TLS";
private static final String CERTIFICATE_FACTORY_TYPE = "X.509";
public static void main(String args[])
try
try{
temp tmp = new temp();
String url = "https://test.mysite.com/one/perform.jsp?mode=get&check=true";
tmp.sendRequest(url);
}catch(Exception e)
e.printStackTrace();
catch(Exception e){
e.printStackTrace();
public String sendRequest(String urlString) throws Exception
StringBuffer response = null;
BufferedReader messageReader = null;
try
String username = "user";
String password = "pwd";
String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes());
//java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
//System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
// Needed for validation of the server certificate
//System.setProperty("javax.net.ssl.trustStore","C:\\cert\\key.txt");
// Needed for providing a clint certificate for client authentication
//System.setProperty("javax.net.ssl.keyStore","C:\\cert\\key.txt");
//System.setProperty("javax.net.ssl.keyStorePassword","te5t1ng");
//System.setProperty("ssl.SocketFactory.provider", "com.sun.net.ssl.internal.ssl.Provider");
KeyStore ks;
ks = KeyStore.getInstance("JKS");
CertificateFactory cf = CertificateFactory.getInstance(CERTIFICATE_FACTORY_TYPE);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(CERTIFICATE_TYPE);
KeyManagerFactory kmf = KeyManagerFactory.getInstance(CERTIFICATE_TYPE);
FileInputStream fis = new FileInputStream("C:\\cert\\key.txt");
BufferedInputStream bis = new BufferedInputStream(fis);
Collection c = cf.generateCertificates(fis);
Iterator i = c.iterator();
while (i.hasNext()) {
java.security.cert.Certificate cert = (java.security.cert.Certificate)i.next();
System.out.println(cert);
ks.load(null, null);
X509Certificate the_cert = (X509Certificate)cf.generateCertificate(bis);
ks.setCertificateEntry("server_cert",the_cert);
tmf.init(ks);
ks = KeyStore.getInstance(KEYSTORE_TYPE);
ks.load(null, null);
the_cert = (X509Certificate)cf.generateCertificate(new FileInputStream("key.txt"));
ks.setCertificateEntry("client_cert",the_cert);
kmf.init(ks, null);
SSLContext ctx = SSLContext.getInstance(SSL_PROTOCOL);
KeyManager[] km = kmf.getKeyManagers();
TrustManager[] tm = tmf.getTrustManagers();
ctx.init (km, tm, null);
HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
urlString = urlString.replaceAll(" ","%20");
URL url = new URL(urlString);
//HttpsURLConnection urlCon = (HttpsURLConnection)url.openConnection();
HttpURLConnection urlCon = (HttpURLConnection)url.openConnection();
//com.sun.net.ssl.HttpsURLConnection urlCon = (com.sun.net.ssl.HttpsURLConnection)urlCon;
/*urlCon.setRequestProperty("Host", url.getHost());*/
urlCon.setDoOutput(true);
urlCon.setDoInput(true);
urlCon.setRequestMethod("POST");
urlCon.setUseCaches (false);
urlCon.setAllowUserInteraction(true);
urlCon.setInstanceFollowRedirects(true);
urlCon.setRequestProperty ("Authorization", "Basic " + encoding);
//Permission permision = urlCon.getPermission();
//System.out.println("permission name:"+permision.getName());
urlCon.connect();
//messageReader = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
//response = new StringBuffer();
//String line;
//while((line = messageReader.readLine()) != null){
// response.append(line);
// response.append("\n");
catch (Exception e) {
e.printStackTrace();
throw e;
return "testing";sorry for the junk data.. Need to post it again
-
IIS Webgate losing connection to OAM server with query string in URI
Hi,
We have a Windows 2008 server with IIS 7/7.5 and the OAM 10.1.4.3 webgate installed on it, and are having a problem where it appears that during the processing of a request, the webgate is getting an ErrEngineDown (i.e., the webgate thinks that it's lost connection to the OAM server).
We have a number of similarly configured IIS servers + webgates that work fine, but this problem is only occurring on one of the IIS servers, AND it appears that this only happens when the URI being requested includes a query string.
When this happens, we see the following in the webgate oblog.log file:
2012/10/08@16:45:10.244000 3148 2928 CONN_MGMT DEBUG1 0x00000201 ..\src\aaa_service_client.cpp:935 "Simulating engine down reply"
and:
2012/10/08@16:45:10.244000 3148 3220 WEB TRACE 0x00000203 ..\src\iis_filt_info.cpp:554 "Function entered" _TraceName^ObIISFiltPreprocHdrs::RedirectTo redirectUrl^/access/oblix/apps/webgate/bin/webgate.dll?status%253D500%2520errmsg%253DErrEngineDown
and:
2012/10/08@16:45:10.244000 3148 3220 ACCESS_CLIENT DEBUG3 0x00000201 ..\src\aaa_service_client.cpp:3359 "ObAAAServiceClient::DecNumActiveReferences" _numActiveReferences^0 AAA Client Address^0x02139730
2012/10/08@16:45:10.244000 3148 3220 ACCESS_SDK ERROR 0x00000501 ..\src\obuser_session.cpp:1564 "ObError exception caught" raw_code^124
We've confirmed that the IIS server connectivity to the OAM server is fine.
When they test, they get the OAM FORM login page, then then enter the username and password, and then the browser shows an "Oracle Access Manager Operation Error" webpage (which probably corresponds to that "ErrEnginedown".
The puzzling thing is why this would happen but only if the URI includes a query string. Also, as I mentioned, we are only seeing this problem with one IIS server (+webgate).
We have an SR with Oracle, but that hasn't made much progress, so I was wondering if anyone has encountered something like this?
Thanks,
JimHi,
It turned out that there were some application errors that were occurring and when those were fixed, this problem disappeared. We don't control the IIS application, so we're not 100% what the problems were.
Jim -
Need help with query joining several tables into a single return line
what i have:
tableA:
puid, task
id0, task0
id1, task1
id2, task2
tableB:
puid, seq, state
id0, 0, foo
id0, 1, bar
id0, 2, me
id1, 0, foo
id2, 0, foo
id2, 1, bar
tableC:
puid, seq, date
id0, 0, 12/21
id0, 1, 12/22
id0, 2, 12/22
id1, 0, 12/23
id2, 0, 12/22
id2, 1, 12/23
what i'd like to return:
id0, task0, 12/21, 12/22, 12/22
id1, task1, 12/23, N/A, N/A
id2, task2, 12/22, 12/23, N/A
N/A doesn't mean return the string "N/A"... it just means there was no value, so we don't need anything in this column (null?)
i can get output like below through several joins, however i was hoping to condense each "id" into a single line...
id0, task0, 12/21
id0, task0, 12/22
id0, task0, 12/23
id1, task1, 12/23
is this possible fairly easily?
Edited by: user9979830 on Mar 29, 2011 10:53 AM
Edited by: user9979830 on Mar 29, 2011 10:58 AMHi,
Welcome to the forum!
user9979830 wrote:
what i have:...Thanks for posting that so clearly!
Whenever you have a question, it's even better if you post CREATE TABLE and INSERT statements for your sample data, like this:
CREATE TABLE tablea
( puid VARCHAR2 (5)
, task VARCHAR2 (5)
INSERT INTO tablea (puid, task) VALUES ('id0', 'task0');
INSERT INTO tablea (puid, task) VALUES ('id1', 'task1');
INSERT INTO tablea (puid, task) VALUES ('id2', 'task2');
CREATE TABLE tablec
( puid VARCHAR2 (5)
, seq NUMBER (3)
, dt DATE -- DATE is not a good column name
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 0, DATE '2010-12-21');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 1, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 2, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id1', 0, DATE '2010-12-23');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 0, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 1, DATE '2010-12-23');This way, people can re-create the problem and test their ideas.
It doesn't look like tableb plays any role in this problem, so I didn't post it.
Explain how you get the results from that data. For example, why do you want this row in the results:
PUID TASK DT1 DT2 DT3
id0 task0 12/21/2010 12/22/2010 12/22/2010rather than, say
PUID TASK DT1 DT2 DT3
id0 task0 12/22/2010 12/21/2010 12/22/2010? Does 12/21 have to go in the first column because it is the earliest date, or is it because 12/21 is related to the lowest seq value? Or do you even care about the order, just as long as all 3 dates are shown?
Always say what version of Oracle you're uisng. The query below will work in Oracle 9 (and up), but starting in Oracle 11, the SELECT ... PIVOT feature could help you.
i can get output like below through several joins, however i was hoping to condense each "id" into a single line... Condensing the output, so that there's only one line for each puid, sounds like a job for "GROUP BY puid":
WITH got_r_num AS
SELECT puid
, dt
, ROW_NUMBER () OVER ( PARTITION BY puid
ORDER BY seq -- and/or dt
) AS r_num
FROM tablec
-- WHERE ... -- If you need any filtering, put it here
SELECT a.puid
, a.task
, MIN (CASE WHEN r.r_num = 1 THEN r.dt END) AS dt1
, MIN (CASE WHEN r.r_num = 2 THEN r.dt END) AS dt2
, MIN (CASE WHEN r.r_num = 3 THEN r.dt END) AS dt3
, MIN (CASE WHEN r.r_num = 4 THEN r.dt END) AS dt4
FROM tablea a
JOIN got_r_num r ON a.puid = r.puid
GROUP BY a.puid
, a.task
ORDER BY a.puid
;I'm guessing that you want the dates arranged by seq; that is, for each puid, the date related to the lowest seq comes first, regardless of whther that date is the earliest date for that puid or not. If that's not what you need, then change the analytic ORDER BY clause.
This does not assume that the seq values are always consecutive integers (0, 1, 2, ...) for each puid. You can skip, or even duplicate values. However, if the values are always consecutive integers, starting from 0, then you could simplify this. You won't need a sub-query at all; just use seq instead of r_num in the main query.
Here's the output I got from the query above:
PUID TASK DT1 DT2 DT3 DT4
id0 task0 12/21/2010 12/22/2010 12/22/2010
id1 task1 12/23/2010
id2 task2 12/22/2010 12/23/2010As posted, the query will display the first 4 dts for each puid.
If there are fewer than 4 dts for a puid, the query will still work. It will leave some columns NULL at the end.
If there are more than 4 dts for a puid, the query will still work. It will display the first 4, and ignore the others.
There's nothing special about the number 4; you could make it 3, or 5, or 35, but whatever number you choose, you have to hard-code that many columns into the query, and always get that many columns of output.
For various ways to deal with a variable number of pivoted coolumns, see the following thread:
PL/SQL
This question actually doesn't have anything to do with SQL*Plus; it's strictly a SQL question, and SQL questions are best posted on the "SQL and PL/SQL" forum:
PL/SQL
If you're not sure whether a question is more of a SQL question or a SQL*Plus question, then post it on the SQL forum. Many more people pay attention to that forum than to this one. -
Help with querying a webpage without a browser
Hi All,
I am a novice Java programmer trying to complete an assignment. I need to download BibTeX information from www.springerlink.com. As an example, I'm trying to retrieve the text file containing the information I need from the following URL: http://www.springerlink.com/export.mpx?code=h50q051306287335&mode=txt. I used the following method with my url as the string but it returns the homepage and not the actual text file as is the case when I type the url in the browser. By the way I have an institutional log in (and you'll need one to test this :-( ).
public static String URLConnectionReader (String str) {
String output = "";
try {
URL url = new URL(str);
URLConnection uconn = url.openConnection();
HttpURLConnection conn = (HttpURLConnection) uconn;
conn.setInstanceFollowRedirects( true );
BufferedReader in = new BufferedReader(
new InputStreamReader(
conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
output += inputLine;
in.close();
return output;
catch (Exception e) {
System.err.println("Something went wrong...");
e.printStackTrace();
return output;
I found articles online that suggested I query the site. Here's the revised code:
public static String URLConnectionReadWrite () {
String output = "";
try {
URL url = new URL("http://www.springerlink.com");
URLConnection uconn = url.openConnection();
HttpURLConnection conn = (HttpURLConnection) uconn;
conn.setInstanceFollowRedirects( true );
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write("export.mpx?code=h50q051306287335&mode=txt");
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(
conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
output += inputLine;
in.close();
return output;
catch (Exception e) {
System.err.println("Something went wrong...");
e.printStackTrace();
return output;
However, it still returns the homepage. Please does anyone know how I can solve this problem as the result of my project greatly depends on accurately retrieving this data. Thanks in advance!
ChidiThis can be done easily using java script and AJAX. Create an Html file and write scripts to download and save data. Open this page in another browser's tab only after you login to the download site. In that case there should not be any home page issue as session cookie is already available in browser.
-
Hello, I have the following query that I'm running in Oracle SQL Developer 1.2.1
WITH group_by_4_column_results AS
(SELECT m_atschunk.employee AS employee,
SUM(CASE
WHEN
M_ATSCHUNK.rolloffDaysCount = '108545043' AND m_atschunk.infractiondate BETWEEN SYSDATE - 365 AND SYSDATE THEN 1 ELSE 0 END) as rolloffs,
M_ATSCHUNK.INFRACTIONDATE + 365 as infractionDate
FROM M_ATSCHUNK
group by employee, infractionDate, rolloffDaysCount
SELECT g4.*,
SUM (rolloffs) OVER (PARTITION BY employee) AS total_rolloffs
FROM group_by_4_column_results g4
It will output the key elements of what I need. But where it sums up the 'total_rolloffs', I need to add that number back into the infractiondate column. Any help would be greatly appreciated.
CREATE TABLE M_ATSCHUNK
(EMPLOYEE varchar(50),
ROLLOFFDAYSCOUNT varchar(3),
INFRACTIONDATE date)
INSERT INTO M_ATSCHUNK (EMPLOYEE, ROLLINGOFFDAYSCOUNT, INFRACTIONDATE)
VALUES ('PHIL','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/02 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/03 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/04 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','YES', (to_date('2010/01/05 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','NO', (to_date('2010/02/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('PHIL','NO', (to_date('2010/03/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','YES', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss'))),
VALUES ('NIKI','NO', (to_date('2010/01/01 08:00:00', 'yyyy/mm/dd hh24:mi:ss')))Phil3061 wrote:
I need to add that number back into the infractiondate column.Well, in general you need to use UPDATE or better MERGE. Howebver, your data sample does not show any rollofs:
SQL> SELECT * FROM M_ATSCHUNK;
EMPLOYEE ROL INFRACTIO
PHIL YES 01-JAN-10
PHIL YES 02-JAN-10
PHIL YES 03-JAN-10
PHIL YES 04-JAN-10
PHIL YES 05-JAN-10
PHIL NO 01-FEB-10
PHIL NO 01-MAR-10
NIKI YES 01-JAN-10
NIKI YES 01-JAN-10
NIKI YES 01-JAN-10
NIKI NO 01-JAN-10
EMPLOYEE ROL INFRACTIO
NIKI NO 01-JAN-10
NIKI NO 01-JAN-10
NIKI NO 01-JAN-10
14 rows selected.
SQL> WITH group_by_4_column_results AS
2 (SELECT m_atschunk.employee AS employee,
3 SUM(CASE
4 WHEN
5 M_ATSCHUNK.rolloffDaysCount = '108545043' AND m_atschunk.infractiondate BETWEEN SYSDATE - 365 AND SYSDATE THEN 1 ELSE 0 END) as
rolloffs,
6 M_ATSCHUNK.INFRACTIONDATE + 365 as infractionDate
7 FROM M_ATSCHUNK
8 group by employee, infractionDate, rolloffDaysCount
9 )
10 SELECT g4.*,
11 SUM (rolloffs) OVER (PARTITION BY employee) AS total_rolloffs
12 FROM group_by_4_column_results g4
13 /
EMPLOYEE ROLLOFFS INFRACTIO TOTAL_ROLLOFFS
NIKI 0 01-JAN-11 0
NIKI 0 01-JAN-11 0
PHIL 0 01-JAN-11 0
PHIL 0 02-JAN-11 0
PHIL 0 03-JAN-11 0
PHIL 0 04-JAN-11 0
PHIL 0 05-JAN-11 0
PHIL 0 01-FEB-11 0
PHIL 0 01-MAR-11 0
9 rows selected.
SQL> So adjust data sample and based on it tell us what are the expected results.
SY.
Maybe you are looking for
-
Can't Attach Files in 10.9 Mail via Menubar/Toolbar
All of a sudden I cannot attach files in Mail via menu commands. A selection (finder) window opens but all items are grayed out (no matter what location). I can still attach files by dragging them from the Desktop (or other location) into the body
-
Puchased movie in iTunes not showing in Videos
I bought a movie via iTunes ...it shows in my "purchased" and I got a receipt of the charge. Although I'd expect to be able click it there and play (come on Apple!), I finally figured out I had to go to Videos . But only music videos are showing up
-
I cloud system preferences fails to validate storage server credentials. Ical fails to sign in but I can get information on my account from the system preferences. My system is 10.7.5 on a mac pro 1.1. I am very frustrated I hope someone has a soluti
-
FLV video in a single keyframe.
hello, I have loaded an external FLV video into my project however, my video starts immediately as soon as I go to the keyframe with the video on it. It can still be heard playing after I leave that keyframe. Should I return to the keyframe it begins
-
Hello, Anyone can help me with this? I am trying to setup 802.1X Authentication in a HP LaserJet M9050 (MTF) I access to the embeded Web Server in Networking>Security>802.1X Authentication: I tryed with some values but i receive in a radius Server t