Dear Andy Good Morning !
Can you please explain more. How can I fix this problem ?
Because
in outer query I am getting ?pid one by one. in sub query instead of taking
value from outer query subquery is taking value of ?pid from VALUES.

My Problem I want to get Product information and counts of new and used
> offers against each product.


Thank you.
Regards
Nauman

On Sat, Jul 25, 2015 at 9:06 PM, Andy Seaborne <[email protected]> wrote:

> On 25/07/15 12:09, Nauman Ramzan wrote:
>
>> Dear Andy,
>>
>> I am using Jena ARQ.
>>
>> On Sat, Jul 25, 2015 at 3:02 PM, Nauman Ramzan <
>> [email protected]>
>> wrote:
>>
>>  Hi James Anderson !
>>> Thank you for your help.
>>> Now construct this query
>>>
>>> CONSTRUCT{
>>>
>>>>   ?pid dprop:title ?title;
>>>>        dprop:description ?description;
>>>>        dprop:brand ?brand;
>>>>        dprop:isPublic ?isPublic;
>>>>        dprop:count ?total;
>>>>        dprop:priceMin ?priceMin;
>>>>        dprop:condition ?condition;
>>>>        dprop:createdAt ?createdAt.
>>>> }
>>>> WHERE {
>>>>    ?pid dprop:productTitle ?title;
>>>>      dprop:productDescription ?description;
>>>>      dprop:productBrand ?brand;
>>>>      dprop:isPublic ?isPublic;
>>>>      dprop:createdAt ?createdAt.
>>>>      OPTIONAL { ?pid dprop:bulletpoint0 ?bulletpoint0 }
>>>>      OPTIONAL { ?pid dprop:bulletpoint1 ?bulletpoint1 }
>>>>      {
>>>>        SELECT (COUNT(?cond) AS ?total) (MIN(?pr) AS ?priceMin )
>>>>   ?condition WHERE{
>>>>          ?pid ^mod:isOfferOf ?oid.
>>>>          ?oid dprop:price ?pr.
>>>>          ?oid dprop:condition ?cond.
>>>>          BIND (if( ?cond = 1, "New", "Used") AS ?condition).
>>>>        }
>>>>      }
>>>>    VALUES ?pid { prod:Rl5RVl5R  prod:Rl5RVl5Q prod:Rl5RVl5W
>>>> prod:Rl5RVl5Y
>>>> prod:Rl5RVl5U }
>>>> }
>>>>
>>>
>>>
>>> Everything is working fine. except sub-query calculation error. result of
>>> total is not correct.
>>>
>>
> That maybe because there are 2 different ?pid variables.
>
> >>>        SELECT (COUNT(?cond) AS ?total) (MIN(?pr) AS ?priceMin )
> >>>   ?condition WHERE{
> >>>          ?pid ^mod:isOfferOf ?oid.
> >>>          ?oid dprop:price ?pr.
> >>>          ?oid dprop:condition ?cond.
> >>>          BIND (if( ?cond = 1, "New", "Used") AS ?condition).
> >>>        }
>
> ?pid is not projected out so it is not joined with the one in the VALUEs
> clause.  You could GROUP BY ?pid and add it to the SELECT clause.  You can
> also just have
>
> WHERE {
>   SELECT ... { ... }
>   GROUP BY ?pid
> }
>
> with everything inside the SELECT's {}
>
>         Andy
>
>
>  My schema(relation between product and offer ) you can see in first
>>> message.
>>>
>>> On Sat, Jul 25, 2015 at 1:00 PM, Andy Seaborne <[email protected]> wrote:
>>>
>>>  On 25/07/15 04:54, Nauman Ramzan wrote:
>>>>
>>>>  Hi Here is my question in details. Now i am getting counts and other
>>>>> info.
>>>>> but i want to define/use this result as data of outer block.
>>>>>
>>>>>
>>>>> http://answers.semanticweb.com/questions/32850/sparql-use-subquery-as-resultvariable-for-outer-query
>>>>> same as
>>>>>
>>>>>
>>>>> http://stackoverflow.com/questions/31586989/sparql-use-subquery-as-result-variable-for-outer-query
>>>>> Thank you.
>>>>>
>>>>>
>>>> The query isn't legal SPARQL (parse error - non-group'ed variables in
>>>> the
>>>> inner select - even after completing the prefixes).  Previously, you
>>>> indicated you were using Virtuoso.  Their support lists are on
>>>> SourceForge.
>>>>
>>>> It will help them to have a complete, minimal example.
>>>>
>>>>    A small amount of data
>>>>    A complete working query
>>>>
>>>>          Andy
>>>>
>>>>
>>>>
>>>>  On Tue, Jul 21, 2015 at 5:04 PM, Andy Seaborne <[email protected]>
>>>>> wrote:
>>>>>
>>>>>   On 21/07/15 11:35, Nauman Ramzan wrote:
>>>>>
>>>>>>
>>>>>>   Hi all !
>>>>>>
>>>>>>> I have this type of data
>>>>>>>
>>>>>>>    <offer1> rdf:isOfferOf <product1>
>>>>>>>
>>>>>>>  <offer2> rdf:isOfferOf <product1>
>>>>>>>> <offer3> rdf:isOfferOf <product2>
>>>>>>>> <offer4> rdf:isOfferOf <product2>
>>>>>>>>
>>>>>>>>    <offer5> rdf:isOfferOf <product2>
>>>>>>>>
>>>>>>>>
>>>>>>> <offer7> rdf:isOfferOf <product7>
>>>>>>>
>>>>>>> now I want to get all offers of product1, product2.
>>>>>>> second counts of offers.
>>>>>>> Thank you
>>>>>>>
>>>>>>>
>>>>>>>   What have you tried?
>>>>>>>
>>>>>>
>>>>>> A complete, minimal example of what you have tried makes it easier to
>>>>>> answer the question.
>>>>>>
>>>>>>           Andy
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Reply via email to