Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Oracle] not a "Group By" expression, Problem mit inner SELECT

Empfohlene Antworten

Veröffentlicht

Hmm ... ein SQL will nicht so recht:

SELECT 

TRIM(TO_CHAR(m1.mdate,'D')) AS mday

,SUM(m1.mood * m1.mcount) / SUM(m1.mcount) AS maverage

,SUM(m1.mcount) / (SELECT count(distinct m2.mdate) FROM u_moodsensor.mood m2 WHERE TO_CHAR(m2.mdate,'D')=TO_CHAR(m1.mdate,'D') GROUP BY TO_CHAR(m2.mdate,'D')) AS mcount

FROM u_moodsensor.mood m1 

GROUP BY TO_CHAR(m1.mdate,'D')

ORDER BY 1;
=> dieses geht nicht ... Aber dieses geht einwandfrei (TO_CHAR(m1.mdate,'D') mit '2' ersetzt)
SELECT 

TRIM(TO_CHAR(m1.mdate,'D')) AS mday

,SUM(m1.mood * m1.mcount) / SUM(m1.mcount) AS maverage

,SUM(m1.mcount) / (SELECT count(distinct m2.mdate) FROM u_moodsensor.mood m2 WHERE TO_CHAR(m2.mdate,'D')='2' GROUP BY TO_CHAR(m2.mdate,'D')) AS mcount

FROM u_moodsensor.mood m1 

GROUP BY TO_CHAR(m1.mdate,'D')

ORDER BY 1;

Weiss jemand wieso?

Grüße

scratch

  • Autor

Hab die Lösung ... ich habs mir komplizierter gemacht als ich musste ;)

So gehts (ohne Subquery):

SELECT 

TRIM(TO_CHAR(mdate,'D')) AS mday

,SUM(mood * mcount) / SUM(mcount) AS maverage

,SUM(mcount) / COUNT(DISTINCT mdate) AS mcount 

FROM u_moodsensor.mood 

GROUP BY TRIM(TO_CHAR(mdate,'D')) 

ORDER BY 1

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.