sql сгруппировать значения, если они одинаковы - PullRequest
0 голосов
/ 27 декабря 2011

Я написал sql-серверный код и таблицу Coldfusion, с продуктами и ценами, каждый продукт имеет 5 разных цен, и все цены отображаются правильно, хотя они отличаются друг от друга, но если цены на продукты 5 одинаковыони сгруппированы как одно.В любом случае надеюсь, что все будет ясно из кода и снимка экрана.

<tr class="color-header">
        <td width="170"><b>Ürün</b></td>
        <td class="header_bold"><b>Açıklama 2</b></td>
        <td class="header_bold" width="100"><b>Marka</b></td>
        <cfif isdefined('attributes.department_id') and len(attributes.department_id)>
        <td class="header_bold" width="35"><b>Depo Stok</b></td>
        <cfelse>
            <td class="header_bold" width="35"><b>Stok</b></td>
            <td class="header_bold" width="50"><b>Satabilen Stok</b></td>
            <td class="header_bold" width="35"><b>Yoldaki Stok</b></td>
        </cfif>
        <cfif (session.ep.admin is 1) or (session.ep.userid is 19)>
            <td class="header_bold" width="70">Dön. Sonu B.Maliyet $</td>
        </cfif>
        <td class="header_bold" width="90">Liste Fiatı</td>
        <td class="header_bold" <cfif isdefined('get_company.companycat_id') and len(get_company.companycat_id) and (get_company.companycat_id eq 6)>style="color:yellow;font-size:9pt;background:#000;"</cfif> width="80">Bayi 1</td>
        <td class="header_bold" <cfif isdefined('get_company.companycat_id') and len(get_company.companycat_id) and (get_company.companycat_id eq 7)>style="color:yellow;font-size:9pt;background:#000;"</cfif> width="80">Bayi 2 <br /> 12 Ay 0 faiz</td>
        <td class="header_bold" <cfif isdefined('get_company.companycat_id') and len(get_company.companycat_id) and (get_company.companycat_id eq 8)>style="color:yellow;font-size:9pt;background:#000;"</cfif> width="80">Bayi 3 <br /> 30-60-90 çek</td>
        <td class="header_bold" <cfif isdefined('get_company.companycat_id') and len(get_company.companycat_id) and (get_company.companycat_id eq 9)>style="color:yellow;font-size:9pt;background:#000;"</cfif> width="80">Bayi 4 Tek Çekim Peşin</td>
        <cfif (session.ep.admin is 1) or (session.ep.userid is 19)>
        <td class="header_bold" width="60">
            <cfif isdefined('attributes.yoldaki_stock') and attributes.yoldaki_stock is 1>
                Yoldaki
            <cfelseif isdefined('attributes.department_id') and len(attributes.department_id)>
                Depodaki
            <cfelse>
                Satabilen
            </cfif>Hesapla
        </td>
        </cfif>
        <td class="header_bold" width="25">Para</td>
    </tr>

    <cfoutput query="get_products" startrow="#attributes.startrow#" maxrows="#attributes.maxrows#" group="product_id">
            <cfquery name="get_maliyet" datasource="#dsn3#">SELECT PURCHASE_NET_SYSTEM_MONEY,(PURCHASE_NET_SYSTEM+PURCHASE_EXTRA_COST_SYSTEM) AS DS_MALIYET FROM PRODUCT_COST WHERE PRODUCT_ID=#PRODUCT_ID#</cfquery><cfif len(get_maliyet.ds_maliyet)><cfset toplam_maliyet=get_maliyet.ds_maliyet+toplam_maliyet></cfif>
            <tr height="20" onMouseOver="this.className='color-light';" onMouseOut="this.className='color-row';" class="color-row"> 
                <td>
                    <a href="/index.cfm?fuseaction=product.form_upd_product&pid=#product_id#" style="color:blue;" target="_blank">#left(product_name,25)#</a>
                </td>
                <td>#left(PRODUCT_DETAIL2,45)#</td>
                <td align="center"><cfif len(brand_list)>#get_brands.brand_name\[listfind(brand_list,brand_id,',')\]#</cfif></td>
                <cfif isdefined('attributes.department_id') and len(attributes.department_id)>
                    <td align="center">#product_stock2#</td>
                <cfelse>
                    <td align="center">#PRODUCT_STOCK#</td>
                    <td align="center">#saleable_stock#</td>
                    <td align="center">#purchase_order_stock#</td>
                </cfif>
                <cfif (session.ep.admin is 1) or (session.ep.userid is 19)>
                    <td align="center"><cfif len(GET_MALIYET.DS_MALIYET)>#tlformat(GET_MALIYET.DS_MALIYET/get_money.rate2,2)#<cfelse>0</cfif></td>
                </cfif>
                <cfoutput>
                    <td align="center">#tlformat(price,2)#</td>
                </cfoutput>
            <cfif (session.ep.admin is 1) or (session.ep.userid is 19)>
                <td align="center"><a href="javascript://" onclick="gizle_goster(abr#currentrow#);" style="font-weight:bold;"><cfif isdefined('attributes.yoldaki_stock') and attributes.yoldaki_stock is 1>x #purchase_order_stock#<cfelseif isdefined('attributes.department_id') and len(attributes.department_id)>x #product_stock2#<cfelse>x #saleable_stock#</cfif></a></td>
            </cfif>
            <td align="center">#MONEY#</td>
        </tr>
</cfoutput>

на скриншоте вы можете быстро узнать и понять проблему.Конечно, я немного отредактировал код и удалил ненужные части.Всем спасибо за помощь!^^

clearifying screenshot

1 Ответ

0 голосов
/ 27 декабря 2011

В вашем запросе SQL вы группируете по полю цены, поэтому он объединяет эти записи в одну, прежде чем возвращает результаты в ColdFusion. Удалите столбец цены из предложения GROUP BY запроса, и это следует исправить.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...