Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
angela_g
Starting Member
17 Posts |
Posted - 2014-03-21 : 07:40:37
|
Hi AllI am trying to create a select query similar to the following but the problem I am having is that I want to only select one record where there may be several with the same dw_order_no. Can anyone help please? I have tried various ways using SQL developer but without successSELECT VE_EZP_ORDER_TRANS.EZP_BILL_STATUS AS EZP_BILL_STATUS1, VE_EZP_AGED_CUSTOMER_DEBT.SURNAME, VE_EZP_AGED_CUSTOMER_DEBT.DEBT_AGE_CATEGORY, VE_EZP_AGED_CUSTOMER_DEBT.DEBT_AGE, VE_ORDERLINE.DW_ORDER_NO, VE_ORDERLINE.PRD_SKN_NO, VE_ORDERLINE.ORDER_DATEFROM VE_ORDERLINEINNER JOIN VE_EZP_ORDER_TRANSON VE_ORDERLINE.DW_ORDER_NO = VE_EZP_ORDER_TRANS.DW_ORDER_NOINNER JOIN VE_EZP_AGED_CUSTOMER_DEBTON VE_EZP_ORDER_TRANS.DW_ORDER_NO = VE_EZP_AGED_CUSTOMER_DEBT.DW_ORDER_NOWHERE VE_ORDERLINE.PRD_SKN_NO = '400063'AND VE_ORDERLINE.ORDER_DATE >= TO_DATE('2013-03-01', 'YYYY-MM-DD')GROUP BY VE_ORDERLINE.DW_ORDER_NOHAVING (COUNT (VE_ORDERLINE.DW_ORDER_NO) > 1);Here is the error message I receiveORA-00979: not a GROUP BY expression00979. 00000 - "not a GROUP BY expression"*Cause: *Action:Error at Line: 1 Column: 8 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-03-21 : 08:33:10
|
This forum is for Microsoft SQL Server; so there are few if any who have expertise on Oracle and SQL Developer. You might try dbforums.comIf you were on Microsoft SQL Server, using the row_number function would be one way to achieve what you are trying to do. |
 |
|
angela_g
Starting Member
17 Posts |
Posted - 2014-03-21 : 08:37:03
|
ok thank you! |
 |
|
Monib
Starting Member
11 Posts |
Posted - 2014-03-24 : 03:35:35
|
Hi SELECT VE_EZP_ORDER_TRANS.EZP_BILL_STATUS AS EZP_BILL_STATUS1,VE_EZP_AGED_CUSTOMER_DEBT.SURNAME,VE_EZP_AGED_CUSTOMER_DEBT.DEBT_AGE_CATEGORY,VE_EZP_AGED_CUSTOMER_DEBT.DEBT_AGE,VE_ORDERLINE.DW_ORDER_NO,VE_ORDERLINE.PRD_SKN_NO,VE_ORDERLINE.ORDER_DATEFROM VE_ORDERLINEINNER JOIN VE_EZP_ORDER_TRANSON VE_ORDERLINE.DW_ORDER_NO = VE_EZP_ORDER_TRANS.DW_ORDER_NOINNER JOIN VE_EZP_AGED_CUSTOMER_DEBTON VE_EZP_ORDER_TRANS.DW_ORDER_NO = VE_EZP_AGED_CUSTOMER_DEBT.DW_ORDER_NOWHERE VE_ORDERLINE.PRD_SKN_NO = '400063'AND VE_ORDERLINE.ORDER_DATE >= TO_DATE('2013-03-01', 'YYYY-MM-DD')AND VE_ORDERLINE.ORDER_DATE IN(select VE_ORDERLINE.ORDER_DATE frin VE_ORDERLINE group by VE_ORDERLINE) having count(VE_ORDERLINE) > 1) |
 |
|
|
|
|
|
|