
SELECT * 
FROM `manuorder` , `manusummary` , `manustep` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId` 
AND `manustep`.`sMachine` LIKE '%Miyano BND%' 
AND `manuorder`.`nStatus` <4 


SELECT manuorder.sTitle, manuorder.nNumItems, sMatType, fMatDiameter, fMatWidth, fMatHeight, fMatSW, sMachine 
FROM `manuorder` , `manusummary` , `manustep` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId` 
AND `manustep`.`sMachine` LIKE '%Miyano BND%' 
AND `manuorder`.`nStatus` <4 



SELECT manuorder.sTitle, company, contact , manuorder.nNumItems, manuorder.nCustomerId, sMatType, fMatDiameter, fMatWidth, fMatHeight, fMatSW, sMachine 
FROM `manuorder` , `manusummary` , `manustep`, `customer` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId`
AND `manuorder`.`nCustomerId` = `customer`.`customerid` 
AND `manustep`.`sMachine` LIKE '%Miyano BND%' 
AND `manuorder`.`nStatus` <4 



SELECT 
manuorder.sTitle, manuorder.nNumItems, manuorder.sDescription, manuorder.nCustomerId, manuorder.nProductId, manuorder.nProductId,
customer.company, customer.contact, 
sMatType, fMatDiameter, fMatWidth, fMatHeight, fMatSW, sMachine 
FROM `manuorder` , `manusummary` , `manustep`, `customer` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId`
AND `manuorder`.`nCustomerId` = `customer`.`customerid` 
AND `manustep`.`sMachine` LIKE '%Miyano BND%' 
AND `manuorder`.`nStatus` <4 



SELECT 
`manuorder`.`sTitle`, 
`manuorder`.`nNumItems`, 
`manuorder`.`sDescription`, 
`manuorder`.`nCustomerId`, 
`manuorder`.`nProductId`, 
`manuorder`.`nProductId`,
`customer`.`company`, 
`customer`.`contact`, 
`manusummary`.`sMatType`, 
`manusummary`.`fMatDiameter`, 
`manusummary`.`fMatWidth`, 
`manusummary`.`fMatHeight`, 
`manusummary`.`fMatSW`, 
`manustep`.`sMachine`, 
`products`.`sProductnumber`, 
`products`.`sTitle_de`  
FROM `manuorder` , `manusummary` , `manustep`, `customer`, `products` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId`
AND `manuorder`.`nCustomerId` = `customer`.`customerid`
AND `manuorder`.`nProductId` = `products`.`productid`
AND `manustep`.`sMachine` LIKE '%Miyano BND%' 
AND `manuorder`.`nStatus` < 4 


SELECT 
`manuorder`.`sTitle` , 
`manuorder`.`nNumItems` , 
`manuorder`.`sDescription` , 
`manuorder`.`sCreator` , 
`manuorder`.`nCustomerId` , 
`manuorder`.`nProductId` , 
`manuorder`.`dDeliveryDate` , 
`customer`.`company` , 
`customer`.`contact` , 
`manusummary`.`sMatType` , 
`manusummary`.`fMatDiameter` , 
`manusummary`.`fMatWidth` , 
`manusummary`.`fMatHeight` , 
`manusummary`.`fMatSW` , 
`manustep`.`sMachine` , 
`products`.`sProductnumber` , 
`products`.`sTitle_de` 
FROM `manuorder` , `manusummary` , `manustep` , `customer` , `products` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId` 
AND `manuorder`.`nCustomerId` = `customer`.`customerid` 
AND `manuorder`.`nProductId` = `products`.`productid` 
AND `manustep`.`sMachine` LIKE '%Miyano BND%'
AND `manuorder`.`nStatus` < 4
AND `manuorder`.`sCreator` LIKE '%Drescher%'
 	



SELECT `products`.`sProductnumber` , `products`.`sTitle_de` 
FROM `products` 
WHERE `productid` =775


SELECT company, contact 
FROM `customer` 
WHERE `customerid` =1001



 
manuorderid  sTitle  sDescription  sCreator  CreationDateTime  nStatus  
nProductId  nManuSummaryId  nCustomerId  sLexWareNum  nNumItems  nRejectPercentage  
dPSOP  dSOP  dEOP  dDeliveryDate  sSelectedSupplier  listOrderDocumentIds  sRemark  
manusummaryid  nProductId  sTitle  fPartLength  fRawPartLength  sMatType  sMatQuality  
sMatSurface  sMatTolerance  fMatWidth  fMatHeight  fMatSW  fBarLength  fDensity  fMatDiameter  
sDescription  sCreator  CreationDateTime  listDocumentFileIds  sStatus  manustepid  nProductId  
nManuSummaryId  nSequence  sTitle  sCreator  CreationDateTime  sChanger  ChangeDateTime  sMachine  
tRunTime [sec] tSupportTime [min] tPrepTime [min] mDetails  listFileId  sXMLTool  sStatus







SELECT * 
FROM `tablehistory` 
WHERE `sTableName` = 'manuorder'
AND `nReleasePosition` <4
AND `nApproval` =1


SELECT `manuorderid` , `sTitle` , `sDescription` , `sCreator` , `nProductId` , `nCustomerId` , `nNumItems` 
FROM `manuorder` 

SELECT manuorderid, sTableName , sReleaseText, nReleasePosition, nApproval 
FROM `tablehistory` , manuorder
where tablehistory.nTableIndex = manuorder.manuorderid
AND `nReleasePosition` <2
AND `nApproval` =1

SELECT nTableIndex  FROM `tablehistory`
WHERE `sTableName` = 'manuorder'  
AND `nReleasePosition` <3
AND `nApproval` =1

SELECT DISTINCT manuorderid, sTitle , sReleaseText, nReleasePosition
FROM `tablehistory` , manuorder
WHERE tablehistory.nTableIndex = manuorder.manuorderid
AND `nReleasePosition` <4
AND `nApproval` =1



SELECT manuorderid, sTitle, sTableName, sReleaseText, nReleasePosition, nApproval
FROM `tablehistory` , manuorder
WHERE tablehistory.nTableIndex = manuorder.manuorderid
AND `nApproval` =1
AND nReleasePosition <3
GROUP BY manuorderid

SELECT *
FROM `tablehistory`
WHERE `nApproval` =1
AND nReleasePosition <3
GROUP BY nTableIndex

SELECT * 
FROM `tablehistory` 
WHERE `nApproval` =1
AND nReleasePosition >4
GROUP BY nTableIndex






SELECT * 
FROM tablehistory WHERE 
nApproval = 1
AND (historyindex,nReleasePosition) IN 
( SELECT historyindex, MAX(nReleasePosition)
  FROM tablehistory
  GROUP BY historyindex
)

SELECT tt.*
FROM topten tt
INNER JOIN
    (SELECT home, MAX(datetime) AS MaxDateTime
    FROM topten
    GROUP BY home) groupedtt 
ON tt.home = groupedtt.home 
AND tt.datetime = groupedtt.MaxDateTime



Department

Employee

Salary

Department Employee Salary
A John 1000 
A Michael 1200 
A Bob 880 
B Ted 2000 
B Jane 2000 
C Ally 2000 
C Kent 4000 


SELECT 
  DEP.DEPARTMENT, MAX(DEP.SALARY) 
FROM 
  DEPARTMENT DEP 
GROUP BY 
  DEP.DEPARTMENT
  
SELECT * FROM DEPARTMENT 
WHERE 
  EXISTS (
    SELECT 
      DEP.DEPARTMENT 
    FROM 
      DEPARTMENT DEP 
    GROUP BY 
      DEP.DEPARTMENT 
    HAVING 
      DEPARTMENT.DEPARTMENT = DEP.DEPARTMENT AND 
      DEPARTMENT.SALARY = MAX(DEP.SALARY)
  )



ProductID

ProductName

SupplierID

CategoryID

Unit

Price  



SELECT * 
FROM `tablehistory` 
WHERE `nApproval` =0
AND nReleasePosition <4
GROUP BY `nTableIndex` 



 
manuorderid  sTitle  sDescription  sCreator  CreationDateTime  nStatus  
nProductId  nManuSummaryId  nCustomerId  sLexWareNum  nNumItems  nRejectPercentage  
dPSOP  dSOP  dEOP  dDeliveryDate  sSelectedSupplier  listOrderDocumentIds  sRemark  
manusummaryid  nProductId  sTitle  fPartLength  fRawPartLength  sMatType  sMatQuality  
sMatSurface  sMatTolerance  fMatWidth  fMatHeight  fMatSW  fBarLength  fDensity  fMatDiameter  
sDescription  sCreator  CreationDateTime  listDocumentFileIds  sStatus  manustepid  nProductId  
nManuSummaryId  nSequence  sTitle  sCreator  CreationDateTime  sChanger  ChangeDateTime  sMachine  
tRunTime [sec] tSupportTime [min] tPrepTime [min] mDetails  listFileId  sXMLTool  sStatus





  
11 Bestellung 119118 Sehr eilig!!!! Aus 3 Stangen mglichst viele Teile... Matthias Drescher 2016-06-13 15:28:50 3 697 56 1001 NULL 210 5 2016-06-20 NULL NULL 2016-06-24 NULL NULL NULL 56 697 Fertigung Konus 10110622 32 35 Rundmaterial 1.4112 geschliffen h9 NULL NULL NULL 3000 NULL 11 QS-Formular von Halis benutzen !!!!! Matthias Drescher 2016-06-13 15:22:34 NULL In Arbeit 119 697 56 1 Fertigung auf BND Matthias Drescher 2016-06-13 15:24:33 Matthias Drescher 2016-07-05 11:39:47 MIYANO BND 77 15 120 Spannzange fuer BND wurde bei Schlenker bestellt 124,125,126 NULL In Arbeit 
14 Lager Beschreibung Matthias Drescher 2016-06-14 09:37:29 3 694 60 904 NULL 325 5 2016-06-13 NULL NULL 2016-06-14 NULL NULL NULL 60 694 Fertigung FSR 35/30/M8 R1.5 auf BND 30 33.2 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 35 NULL Matthias Drescher 2016-06-14 09:39:24 NULL In Arbeit 124 694 60 1 Drehen auf BND Matthias Drescher 2016-06-14 09:40:48 Matthias Drescher 2016-06-14 09:42:39 MIYANO BND 78 10 90 NULL NULL NULL In Arbeit 
15 Projekt Y 714 Auch Lagerartikel Matthias Drescher 2016-06-15 10:09:44 3 702 68 175 NULL 300 5 2016-06-15 NULL NULL 2016-06-20 NULL NULL NULL 68 702 Fertigung 2011.H.14.1 auf BND 15 18 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 18 NULL Beatrix Schrder 2016-06-17 15:09:45 NULL In Arbeit 136 702 68 1 Drehen auf BND Beatrix Schrder 2016-06-17 15:10:37 Matthias Drescher 2016-07-04 11:26:32 MIYANO BND 96 5 120 Bitte beachten: Rohr D14. muss locker passen!!!!Au... NULL NULL In Arbeit 
19 Bestellung 119287, Kom. 111860 Beschreibung Beatrix Schrder 2016-06-17 15:59:19 3 709 70 1001 NULL 200 5 NULL NULL NULL 2016-06-30 NULL NULL NULL 70 709 Fertigung Konus10215317 auf BND 45 48 Rundmaterial 1.4125 geschliffen  gehrtet NULL NULL NULL 3000 NULL 12 NULL Beatrix Schrder 2016-06-17 15:51:52 NULL In Arbeit 138 709 70 1 Drehen auf BND Beatrix Schrder 2016-06-17 15:54:51 Beatrix Schrder 2016-07-22 14:24:43 MIYANO BND 37 10 NULL NULL NULL NULL In Arbeit 
24 Lager Bestellung Schachermayer liegt vor. Sind mit ca.10... Beatrix Schrder 2016-06-24 10:26:02 3 712 74 1618 NULL 594 5 NULL NULL NULL 2016-06-27 NULL NULL NULL 74 712 Fertigung 1075/060 auf BND oder STAR 60 63 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 15 Tablar-/ Wandtrger 15x 60mm, 2x Gew. M6 Beatrix Schrder 2016-06-24 10:19:10 NULL In Arbeit 144 712 74 1 Drehen auf BND Beatrix Schrder 2016-06-24 10:22:49 Beatrix Schrder 2016-07-22 14:03:54 MIYANO BND 43 10 NULL Tablar-/ Wandtrger 15x 60mm, 2x Gew. M6 NULL NULL In Arbeit 
46 Lager Stift fr 1326 und 1327, 8, Lg.35mm, Material 1.4... Beatrix Schrder 2016-07-21 09:50:48 1 752 98 1618 NULL 5000 5 NULL NULL NULL 2016-07-28 NULL NULL NULL 98 752 Fertigung Stift 1386.35 35 38 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 8 Stift fr 1326 und 1327, 8, Lg.35mm, Material 1.4... Beatrix Schrder 2016-07-21 09:47:31 NULL In Arbeit 180 752 98 1 Drehen auf BND Beatrix Schrder 2016-07-21 09:49:32 Beatrix Schrder 2016-07-22 14:28:29 MIYANO BND 15 10 NULL Stift fr 1326 und 1327, 8, Lg.35mm, Material 1.4... NULL NULL In Arbeit 
49 Rckstand Best. Kirchner Beschreibung Beatrix Schrder 2016-07-26 10:38:13 1 758 104 1618 NULL 150 5 NULL NULL NULL 2016-07-29 NULL NULL NULL 104 758 Fertigung K562022 25 28 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 25 Distanz zur UV-Verklebung, 25mm, H: 25mm
Sackloc... Beatrix Schrder 2016-07-26 10:36:22 NULL In Arbeit 190 758 104 1 Drehen Beatrix Schrder 2016-07-26 10:37:40 Petra Drescher 2016-08-10 22:54:21 MIYANO BND NULL NULL NULL NULL NULL NULL In Arbeit 
20 Lager Beschreibung D14x60 Beatrix Schrder 2016-06-21 09:30:52 2 753 97 1618 NULL 2000 5 2015-08-26 NULL NULL 2016-06-24 NULL NULL NULL 97 192 Fertigung Sockel 1327 60 63 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 14 NULL Halis Kamiloglu 2016-07-19 14:36:00 NULL In Arbeit 193 192 97 1 Drehen auf BND Matthias Drescher 2016-08-01 09:07:49 Matthias Drescher 2016-08-01 09:09:31 MIYANO BND 150 10 120 NULL NULL NULL In Arbeit 
35 FSR Rckstand Beschreibung Beatrix Schrder 2016-07-06 08:20:09 1 756 108 823 NULL 1000 5 2016-07-18 NULL NULL 2016-07-08 NULL NULL NULL 108 756 Fertigung auf BND/VF1 59.5 62.5 Rundmaterial 1.4301 geschliffen h9 NULL NULL NULL 3000 NULL 24 NULL Matthias Drescher 2016-08-01 23:03:52 NULL In Arbeit 194 756 108 1 Rohling drehen auf BND Matthias Drescher 2016-08-01 23:04:45 Matthias Drescher 2016-08-01 23:05:30 MIYANO BND NULL NULL NULL NULL NULL NULL In Arbeit 
45 Lager Halterung fr 
Rundmaterial Durchmesser 12mm
Mat... Beatrix Schrder 2016-07-15 08:19:44 1 750 129 1618 NULL 400 5 NULL NULL NULL 2016-07-28 NULL NULL NULL 129 750 Fertigung 2024.12OF 28 31 Rundmaterial 1.4305 geschliffen h9 NULL NULL NULL 3000 NULL 40 Halterung ohne Fase fr 
Rundmaterial Durchmesser... Beatrix Schrder 2016-08-09 13:10:20 NULL In Arbeit 230 750 129 1 Drehen Beatrix Schrder 2016-08-09 13:15:18 Beatrix Schrder 2016-08-09 13:15:55 MIYANO BND 140 NULL NULL Halterung ohne Fase fr 
Rundmaterial Durchmesser... NULL NULL In Arbeit 
48 Lager Bestand tendiert gegen NULL Beatrix Schrder 2016-07-26 10:30:00 1 23 111 1618 NULL 300 5 NULL NULL NULL 2016-08-10 NULL NULL NULL 111 23 Fertigung 2005.50 10 13 Rundmaterial 1.4305 NULL NULL NULL NULL NULL 3000 NULL 50 NULL Matthias Drescher 2016-08-02 10:59:40 NULL In Arbeit 232 23 111 1 Drehen Beatrix Schrder 2016-08-09 13:19:51 Petra Drescher 2016-08-10 23:01:23 MIYANO BND NULL NULL NULL NULL NULL NULL In Arbeit 




SELECT 
`manuorder`.`manuorderid`, `manuorder`.`sTitle`, 
`manuorder`.`nNumItems`, `manuorder`.`sDescription`, 
`manuorder`.`nCustomerId`, `manuorder`.`nProductId`, 
`manuorder`.`dDeliveryDate`, `manuorder`.`nStatus`, 
`customer`.`company`, `customer`.`contact`, `manusummary`.
`sMatType`, `manusummary`.`fMatDiameter`, `manusummary`.`fMatWidth`, 
`manusummary`.`fMatHeight`, `manusummary`.`fMatSW`, `manustep`.`sMachine`, 
`products`.`sProductnumber`, `products`.`sTitle_de` 
FROM `manuorder` , `manusummary` , `manustep`, `customer`, `products` 
WHERE 1 =1 
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId` 
AND `manuorder`.`nCustomerId` = `customer`.`customerid` 
AND `manuorder`.`nProductId` = `products`.`productid` 
AND `manuorder`.`nStatus` < 3 





select group_concat(hobbies separator ', ') from peoples_hobbies where person_id = 5 group by 'all';
SELECT person_id, GROUP_CONCAT(hobbies SEPARATOR ', ') FROM peoples_hobbies GROUP BY person_id



SELECT
GROUP_CONCAT(`manustep`.`sMachine` SEPARATOR ', '), 
`manusummary`.`sMatType` , 
FROM `manustep`, `manusummary`
WHERE 1 = 1
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId`  
AND `manusummary`.`manusummaryid` =2


SELECT sMachine 
FROM `manustep` 
WHERE `nManuSummaryId` =2






SELECT GROUP_CONCAT( sMachine
SEPARATOR ', ' ) AS machines, nProductId, sTitle
FROM `manustep` 
WHERE `nManuSummaryId` =2




SELECT 
`manuorder`.`sTitle` , 
`manuorder`.`nNumItems` , 
`manuorder`.`sDescription` , 
`manuorder`.`sCreator` , 
`manuorder`.`nCustomerId` , 
`manuorder`.`nProductId` , 
`manuorder`.`dDeliveryDate` , 
`customer`.`company` , 
`customer`.`contact` , 
`manusummary`.`sMatType` , 
`manusummary`.`fMatDiameter` , 
`manusummary`.`fMatWidth` , 
`manusummary`.`fMatHeight` , 
`manusummary`.`fMatSW` , 
GROUP_CONCAT( `manustep`.`sMachine` SEPARATOR ', ' ) AS machines, 
`products`.`sProductnumber` , 
`products`.`sTitle_de` 
FROM `manuorder` , `manusummary` , `manustep` , `customer` , `products` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId` 
AND `manuorder`.`nCustomerId` = `customer`.`customerid` 
AND `manuorder`.`nProductId` = `products`.`productid` 
AND `manuorder`.`nStatus` < 4
AND `manuorder`.`sCreator` LIKE '%Drescher%'
 	


SELECT 
`manuorder`.`sTitle` , 
`manuorder`.`nNumItems` , 
`manuorder`.`sDescription` , 
`customer`.`company` , 
`manusummary`.`sMatType` , 
GROUP_CONCAT( `manustep`.`sMachine` SEPARATOR ', ' ), 
`products`.`sProductnumber` , 
`products`.`sTitle_de` 
FROM `manuorder` , `manusummary` , `manustep` , `products` 
WHERE 1 =1
AND `manuorder`.`nManuSummaryId` = `manusummary`.`manusummaryid` 
AND `manusummary`.`manusummaryid` = `manustep`.`nManuSummaryId` 
AND `manuorder`.`nProductId` = `products`.`productid` 
AND `manuorder`.`nStatus` < 4
AND `manuorder`.`sCreator` LIKE '%Drescher%'






