Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid sqlite/Ms sql / sql query
    primarykey
    data
    text
    <p>I have Product Table &amp; priceDeatil table.</p> <pre><code> Prouct Table ProductCode BusinessUnit 10001 ORB 10002 ORB StockRecord Table ProductCode Name StcokQuantity 10001 SUnSilk 1000 10002 Pen 500 priceDeatil ProductCode BusinessUnit price DateFrom DateTo 10001 ORB 12.00 12-08-2011 31-09-2015 10001 ORB 21.00 01.08-2011 15-09-2011 10002 ORB 54.00 21.08-2011 15-09-2011 </code></pre> <p>I want to get the product table's record,StockRecords's table &amp; price with that product latest price</p> <p>Here productCode 10001 contain 2 records when I run query it return 2 reords.I want to get only one records.</p> <pre><code> SELECT WMProduct.BusinessUnit, WMProduct.ProductCode, StockRecord.Name, WMPriceDetail.Price FROM WMProduct INNER JOIN StockRecord ON WMProduct.ProductCode = StockRecord.ProductCode INNER JOIN WMPriceDetail WMPriceDetail ON WMProduct.BusinessUnit = WMPriceDetail.BusinessUnit AND WMPriceDetail.ProductCode = WMProduct.ProductCode WHERE (WMPriceDetail.DateFrom &lt; GETDATE()) AND (WMPriceDetail.DateTo &gt; GETDATE() OR WMPriceDetail.DateTo = NULL) </code></pre> <p>This query returns</p> <pre><code> BusinessUnit ProductCode Name Price ORB 10001 SunSilk 12.00 ORB 10001 SunSilk 21.00 </code></pre> <p>But I need only one records.... BusinessUnit ProductCode Name Price ORB 10001 SunSilk 21.00 ORB 10002 Pen 54.00</p> <p>From that query i can't put <code>TOP 1</code> because there are more table combine.. join</p> <p>If the price is not define in the price detail table, that records should not show into the list.</p> <p>Please help me....</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload