SQL Server Query to generate a model

Copper Contributor

Hello 

I have a table which contains client codes , discounts , sinvoice codes , client names , quantity , date etc... and i want a sql query to generate a model like the picture below so i can put it in a job in SQL server and every day that job runs and generate a csv file containing every client purshases and some other details , the red fields never change and the white ones actually change every csv file like client name _ code etc .... i want help i have tried many methods and i have a tight deadline 

thank yousinvoice number.png

1 Reply
The screenshot is to small to see anything and that's really to less on information.
Please post table design as DDL, some sample data as DML statement and the expected result.